hrev56203 adds 1 changeset to branch 'master'
old head: b3dab377a93967715de129705da699dd54bd1ae7
new head: b2059b9f151d2d6329f9fc4653f352678243f5eb
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=b2059b9f151d+%5Eb3dab377a939
----------------------------------------------------------------------------
b2059b9f151d: libroot: set __main_thread_id in libroot initialize_before
instead of entry point
DT_INIT, DT_INIT_ARRAY, initialize_before, initialize_after are called before
executable entry point so __main_thread_id may be uninitalized there. It cause
getpid() to return zero if called in one of image initalizers before main().
Fixes #11797.
Change-Id: Ia745db9ffeaeb6de4dd46b868b1575d0780b54d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5254
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Tested-by: Commit checker robot <no-reply+buildbot@xxxxxxxxxxxx>
[ X512 <danger_mail@xxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev56203
Commit: b2059b9f151d2d6329f9fc4653f352678243f5eb
URL: https://git.haiku-os.org/haiku/commit/?id=b2059b9f151d
Author: X512 <danger_mail@xxxxxxx>
Date: Wed Apr 27 18:25:55 2022 UTC
Committer: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Commit-Date: Tue Jun 21 11:49:50 2022 UTC
Ticket: https://dev.haiku-os.org/ticket/11797
----------------------------------------------------------------------------
1 file changed, 2 insertions(+), 2 deletions(-)
src/system/libroot/libroot_init.c | 4 ++--
----------------------------------------------------------------------------
diff --git a/src/system/libroot/libroot_init.c
b/src/system/libroot/libroot_init.c
index 52cc2bd7e2..166a83f492 100644
--- a/src/system/libroot/libroot_init.c
+++ b/src/system/libroot/libroot_init.c
@@ -62,7 +62,7 @@ initialize_before(image_id imageID)
}
__libc_argc = __gRuntimeLoader->program_args->arg_count;
- __libc_argv = __gRuntimeLoader->program_args->args;
+ __libc_argv = argv_save = __gRuntimeLoader->program_args->args;
__gRuntimeLoader->call_atexit_hooks_for_range
= _call_atexit_hooks_for_range;
@@ -70,7 +70,7 @@ initialize_before(image_id imageID)
if (__gRuntimeLoader->program_args->umask != (mode_t)-1)
umask(__gRuntimeLoader->program_args->umask);
- pthread_self()->id = find_thread(NULL);
+ __main_thread_id = pthread_self()->id = find_thread(NULL);
get_system_info(&info);
__gCPUCount = info.cpu_count;