sched/task: fix gettid by moving tls_dup_info after child pid initialization

Move tls_dup_info() call to after child process priority is set, ensuring
the child's pid is properly initialized before duplicating TLS information.
This fixes incorrect thread ID assignment during task fork operations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2026-01-20 22:33:45 +08:00
committed by Xiang Xiao
parent c95b6b1bb6
commit 0f7c992cea
+8 -8
View File
@@ -221,14 +221,6 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr)
}
#endif
/* Setup thread local storage */
ret = tls_dup_info(child, parent);
if (ret < OK)
{
goto errout_with_tcb;
}
/* Get the priority of the parent task */
#ifdef CONFIG_PRIORITY_INHERITANCE
@@ -247,6 +239,14 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr)
goto errout_with_tcb;
}
/* Setup thread local storage */
ret = tls_dup_info(child, parent);
if (ret < OK)
{
goto errout_with_tcb;
}
/* Setup to pass parameters to the new task */
ret = nxtask_setup_stackargs(child, argv[0], &argv[1]);