Fix HWASan crashes in heapprofd initialization.

Test: atest perfetto_integrationtests on HWASan build

Bug: 210588740
Change-Id: Iddaa4a7d0dedee541f97bbf0a13958de023bdf59
This commit is contained in:
Florian Mayer 2022-01-31 18:31:48 -08:00
parent 650233457a
commit 6c1c3422a2

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();