pthread: don't destroy the pthread object for the main thread

The pthread object for the main thread initializes its 'Thread_base' base
class part with a reference to the 'Thread_base' object of the Genode main
thread. Therefore the pthread object for the main thread should never be
destroyed, as this would also destroy the Genode 'Thread_base' object.

Fixes #1760
This commit is contained in:
Christian Prochaska 2015-10-28 16:14:13 +01:00 committed by Christian Helmuth
parent be8f16ac3e
commit 97bbc8f965

View File

@ -129,9 +129,16 @@ extern "C" {
if (is_main && !strcmp(name, "main")) {
/* create a pthread object containing copy of main Thread_base */
static struct pthread_attr main_thread_attr;
static struct pthread main(*myself, &main_thread_attr);
static struct pthread *main = nullptr;
if (!main) {
/*
* The pthread object does not get deleted, because this would
* also delete the 'Thread_base' of the main thread.
*/
main = new (Genode::env()->heap()) struct pthread(*myself, &main_thread_attr);
}
return &main;
return main;
}
PERR("pthread_self() called from alien thread named '%s'", name);