From 4697e0e07d5b165b9bfe9150874521cd0a1e7c40 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 25 Nov 2013 11:31:39 +0100 Subject: [PATCH] hw: make bootstrap save against multiple calls In programs with dynamic linker, _main and thus also platform_main_bootstrap are called twice. By now, platform_main_bootstrap tried to always access the startup message in the UTCB of the main thread that gets overridden till the second call. fix #967 --- base-hw/src/platform/main_bootstrap.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/base-hw/src/platform/main_bootstrap.cc b/base-hw/src/platform/main_bootstrap.cc index 69f9fb0e1d..f23455d18d 100644 --- a/base-hw/src/platform/main_bootstrap.cc +++ b/base-hw/src/platform/main_bootstrap.cc @@ -32,6 +32,11 @@ Native_thread_id Genode::thread_get_my_native_id() void Genode::platform_main_bootstrap() { - Native_utcb * const utcb = Thread_base::myself()->utcb(); - _main_thread_id = utcb->startup_msg.thread_id(); + /* go save against multiple calls e.g. for programs with dynamic linker */ + static bool main_thread_id_valid = 0; + if (!main_thread_id_valid) { + Native_utcb * const utcb = Thread_base::myself()->utcb(); + _main_thread_id = utcb->startup_msg.thread_id(); + main_thread_id_valid = 1; + } }