Skip to content

Conversation

@zhangyu-duck
Copy link

Summary

When a task exits, the memory should be released later, otherwise task may continues try get mutex, this moment task'state is already inactive.

nxtask_exit() ->
   nxsched_release_tcb() ->
      addrenv_leave() ->
           addrenv_destroy() ->
               kmm_free()

Impact

optimization task exit process when system enable addrenv

Testing

Just test it when task exit.

When a task exits, the memory should be released later, otherwise a mutex error may occur.

Signed-off-by: zhangyu117 <[email protected]>
@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Jan 12, 2026
@simbit18
Copy link
Contributor

Hi @zhangyu-duck, please note this error

====================================================================================
Configuration/Tool: qemu-intel64/knsh_romfs_pci
2026-01-12 14:29:09
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
addrenv/addrenv.c: In function 'addrenv_destroy':
Error: addrenv/addrenv.c:89:3: error: implicit declaration of function 'kmm_delayfree'; did you mean 'mm_heapfree'? [-Werror=implicit-function-declaration]
   89 |   kmm_delayfree(addrenv);
      |   ^~~~~~~~~~~~~
      |   mm_heapfree
cc1: all warnings being treated as errors
make[1]: *** [Makefile:65: addrenv.o] Error 1
make[1]: Target 'libsched.a' not remade because of errors.
make: *** [tools/LibTargets.mk:71: sched/libsched.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize qemu-intel64/knsh_romfs_pci
====================================================================================

Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing

Just test it when task exit.

Can you please elaborate more on how you tested and verified the correct results?

@xiaoxiang781216
Copy link
Contributor

Hi @zhangyu-duck, please note this error

====================================================================================
Configuration/Tool: qemu-intel64/knsh_romfs_pci
2026-01-12 14:29:09
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
addrenv/addrenv.c: In function 'addrenv_destroy':
Error: addrenv/addrenv.c:89:3: error: implicit declaration of function 'kmm_delayfree'; did you mean 'mm_heapfree'? [-Werror=implicit-function-declaration]
   89 |   kmm_delayfree(addrenv);
      |   ^~~~~~~~~~~~~
      |   mm_heapfree
cc1: all warnings being treated as errors
make[1]: *** [Makefile:65: addrenv.o] Error 1
make[1]: Target 'libsched.a' not remade because of errors.
make: *** [tools/LibTargets.mk:71: sched/libsched.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize qemu-intel64/knsh_romfs_pci
====================================================================================

@zhangyu-duck need upstream delayfree patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants