lib/copperplate: Release main threadobj on exit
PATCH 1/1 lib/copperplate: Release main threadobj on exit
From: Jan Kiszka <[email protected]>
In case of CONFIG_XENO_PSHARED, the main thread's tcb is allocated on the shared heap. Normally, threadobjs are released via the destructor of threadobj_tskey. But this is not called when the main thread terminates so that we leak the object. Fix that by installing an atexit handler that only needs to perform the release now.
Reported-by Mauro S. <[email protected]>
Signed-off-by Jan Kiszka <[email protected]>
--- lib/copperplate/threadobj.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
lib/copperplate/threadobj.c +11 -0
@@ -1770,6 +1770,13 @@ int threadobj_set_schedprio(struct threadobj *thobj, int priority)return threadobj_set_schedparam (thobj, policy, ¶m_ex); } +#ifdef CONFIG_XENO_PSHARED +static void main_exit (void ) +{ +threadobj_free (threadobj_current ()); +} +#endif +static inline int main_overlay (void ) {struct threadobj_init_data idata;
@@ -1806,6 +1813,10 @@ static inline int main_overlay(void)threadobj_prologue (tcb,NULL );pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED ,NULL ); +#ifdef CONFIG_XENO_PSHARED +atexit (main_exit); +#endif +return 0 ; }
Signature · 1 line
2.35.3