Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does memory leak in nxsched_release_tcb for KERNEL mode? #1213

Closed
xiaoxiang781216 opened this issue Jun 7, 2020 · 0 comments · Fixed by #1318
Closed

Does memory leak in nxsched_release_tcb for KERNEL mode? #1213

xiaoxiang781216 opened this issue Jun 7, 2020 · 0 comments · Fixed by #1318
Assignees

Comments

@xiaoxiang781216
Copy link
Contributor

      if (tcb->stack_alloc_ptr &&
          (tcb->flags & TCB_FLAG_CUSTOM_STACK) == 0)
        {
#ifdef CONFIG_BUILD_KERNEL
          /* If the exiting thread is not a kernel thread, then it has an
           * address environment.  Don't bother to release the stack memory
           * in this case... There is no point since the memory lies in the
           * user memory region that will be destroyed anyway (and the
           * address environment has probably already been destroyed at
           * this point.. so we would crash if we even tried it).  But if
           * this is a privileged group, when we still have to release the
           * memory using the kernel allocator.
           */

          if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
#endif
            {
              up_release_stack(tcb, ttype);
            }
        }

Yes, address environment will free the memory when process exit, but the stack memory can't be reused before that. So this is still a memory leak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants