sched/group: prevent mm_free() of static g_kthread_group#18517
sched/group: prevent mm_free() of static g_kthread_group#18517mzanders wants to merge 1 commit intoapache:masterfrom
Conversation
|
I'm not an expert on this matter. I simply added a guard around the failing call. It might be better in terms of group management to handle the case at an earlier stage, I'm open for suggestions if this approach can be improved. |
|
Great test info and explanation! |
|
@mzanders could you please rebase on top of current master there were some esp32 fixes merged recently hope that fixes build issues :-) |
d5ecb71 to
1ec0240
Compare
I was suspecting something like that... Just pushed a rebased version! |
|
@mzanders you need fix: @tmedicci could you help? |
I tried building that target (esp32-devkitc/softap) locally and it works. I'm not sure what to do here... The failing assertion has to do with alignment of linked segments, I really don't see any connection with my change. |
Hi, I'm sorry for the late response. Can you please check which Probably just updating would solve the issue. |
|
Hi @tmedicci, we use this version nuttx/tools/ci/docker/linux/Dockerfile Line 409 in 4aca170 |
The one that comes with my ubuntu 24.04 seems to be 5.2.0. |
|
@tmedicci, is it necessary to update esptool on the Nuttx docker image? |
Hi, |
|
The problem here is Why such change? No clue :-( |
It just gives warning and works for now but later old commands will be dropped. For updates of those commands, there is an open PR #16723. |
|
Maybe for build parts we should use local tools fork to avoid this "deprecation" situations? This is exactly why NuttX avoids external SDKs :-( |
|
Anyway, this change does not seem to be related, @mzanders could you please try rebase again on top of current master? |
When building for small systems with CONFIG_DEFAULT_SMALL=y, this implies CONFIG_DISABLE_PTHREAD and thus HAVE_GROUP_MEMBERS is undefined. When the AppBringUp task finishes, it will in this case try to free g_kthread_group which is obviously not possible. Add a guard with a new flag "GROUP_FLAG_STATIC" which indicates the memory allocation type. Before freeing, check for this flag. Signed-off-by: Maarten Zanders <maarten@zanders.be>
1ec0240 to
13d5479
Compare
Done. Although I don't see any change that would alter the behavior. |
Summary
When building for small systems with CONFIG_DEFAULT_SMALL=y, this implies CONFIG_DISABLE_PTHREAD and thus HAVE_GROUP_MEMBERS is undefined. When the AppBringUp task finishes, it will in this case try to free g_kthread_group which is obviously not possible.
Add a guard with a new flag "GROUP_FLAG_STATIC" which indicates the memory allocation type. Before freeing, check for this flag.
Impact
Builds with CONFIG_DEFAULT_SMALL and CONFIG_DISABLE_PTHREAD are working again.
Testing
Debug summary
Building for olimexino-stm32:nsh (STM32F103RB).
With CONFIG_DEFAULT_SMALL in the defconfig, the target is booting with following stackdump:
Lookup up PC 0x080041b6 in the system map reveals:
Setting a breakpoint with GDB on mm_delayfree() reveals more context. This is the only time the breakpoint is hit; it fails after this.
Note the g_kthread_group in the arguments. It is obvious that a static struct should not be freed.
Fix validation
After patching, the board boots normally: