diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp index 8f1ee9569..91e210e3e 100644 --- a/libc/bionic/libc_init_common.cpp +++ b/libc/bionic/libc_init_common.cpp @@ -54,6 +54,7 @@ extern "C" abort_msg_t** __abort_message_ptr; extern "C" int __system_properties_init(void); extern "C" int __set_tls(void* ptr); extern "C" int __set_tid_address(int* tid_address); +extern "C" int __sinit(void); __LIBC_HIDDEN__ WriteProtected __libc_globals; @@ -133,6 +134,9 @@ void __libc_init_common(KernelArgumentBlock& args) { __pthread_internal_add(main_thread); __system_properties_init(); // Requires 'environ'. + // Initialize stdio here to get rid of data races caused by lazy initialization. + // TODO: Remove other calls to __sinit(). + __sinit(); } __noreturn static void __early_abort(int line) {