diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-01-23 14:47:10 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-23 15:21:10 +0100 |
commit | df6b9cdb0c5eb8d5108d919634846fb63464d1a5 (patch) | |
tree | 06bd7538e5520126877b615e8a3232011f02e5c0 /Userland/Libraries/LibC/libcinit.cpp | |
parent | 888faa3c9f83c8205b3758203b6a1c44f3e7f53d (diff) | |
download | serenity-df6b9cdb0c5eb8d5108d919634846fb63464d1a5.zip |
LibCore+LibC: Enforce the global event loop ban in code
It's a bad idea to have a global event loop in a client application as
that will cause an initialization-order fiasco in ASAN. Therefore, LibC
now has a flag "s_global_initializers_ran" which is false until _entry
in crt0 runs, which in turn only gets called after all the global
initializers were actually executed. The EventLoop constructor checks
the flag and crashes the program if it is being called as a global
constructor. A note next to the VERIFY_NOT_REACHED() informs the
developer of these things and how we usually instantiate event loops.
The upshot of this is that global event loops will cause a crash before
any undefined behavior is hit.
Diffstat (limited to 'Userland/Libraries/LibC/libcinit.cpp')
-rw-r--r-- | Userland/Libraries/LibC/libcinit.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/libcinit.cpp b/Userland/Libraries/LibC/libcinit.cpp index 09d81cbac4..38cab1bdaa 100644 --- a/Userland/Libraries/LibC/libcinit.cpp +++ b/Userland/Libraries/LibC/libcinit.cpp @@ -19,6 +19,7 @@ __thread int errno; char** environ; bool __environ_is_malloced; bool __stdio_is_initialized; +bool s_global_initializers_ran; void* __auxiliary_vector; static void __auxiliary_vector_init(); |