Merge "Fix HWASan crashes in heapprofd initialization." am: 8266380c77 am: a58dd462b1 am: c8089fdc1d

Original change: https://android-review.googlesource.com/c/platform/bionic/+/1965516

Change-Id: I01a1c142ace390e42d915e97b2074fb9f02ac590
This commit is contained in:
Florian Mayer 2022-02-01 21:29:57 +00:00 committed by Automerger Merge Worker
commit 2b1f55294f

View file

@ -93,6 +93,15 @@ static void __libc_preinit_impl() {
__libc_init_common();
__libc_init_scudo();
#if __has_feature(hwaddress_sanitizer)
// Notify the HWASan runtime library whenever a library is loaded or unloaded
// so that it can update its shadow memory.
// This has to happen before _libc_init_malloc which might dlopen to load
// profiler libraries.
__libc_shared_globals()->load_hook = __hwasan_library_loaded;
__libc_shared_globals()->unload_hook = __hwasan_library_unloaded;
#endif
// Hooks for various libraries to let them know that we're starting up.
__libc_globals.mutate(__libc_init_malloc);
@ -101,13 +110,6 @@ static void __libc_preinit_impl() {
__libc_init_fork_handler();
#if __has_feature(hwaddress_sanitizer)
// Notify the HWASan runtime library whenever a library is loaded or unloaded
// so that it can update its shadow memory.
__libc_shared_globals()->load_hook = __hwasan_library_loaded;
__libc_shared_globals()->unload_hook = __hwasan_library_unloaded;
#endif
__libc_shared_globals()->set_target_sdk_version_hook = __libc_set_target_sdk_version;
netdClientInit();