diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index e50e195c46a..e4c373acb30 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -1832,6 +1832,7 @@ long _sys_clone(void *arg[]) rt_thread_t thread = RT_NULL; rt_thread_t self = RT_NULL; int tid = 0; + rt_err_t err; unsigned long flags = 0; void *user_stack = RT_NULL; @@ -1935,6 +1936,9 @@ long _sys_clone(void *arg[]) rt_thread_startup(thread); return (long)tid; fail: + err = GET_ERRNO(); + RT_ASSERT(err < 0); + lwp_tid_put(tid); if (thread) { @@ -1944,7 +1948,7 @@ long _sys_clone(void *arg[]) { lwp_ref_dec(lwp); } - return GET_ERRNO(); + return (long)err; } rt_weak long sys_clone(void *arg[]) diff --git a/components/lwp/lwp_tid.c b/components/lwp/lwp_tid.c index 3e330027de7..e5e4889e4a8 100644 --- a/components/lwp/lwp_tid.c +++ b/components/lwp/lwp_tid.c @@ -88,6 +88,12 @@ int lwp_tid_get(void) current_tid = tid; } lwp_mutex_release_safe(&tid_lock); + + if (tid <= 0) + { + LOG_W("resource TID exhausted."); + } + return tid; }