diff --git a/core/unix/loader.c b/core/unix/loader.c index 88c8ec35e3f..181a03a5af7 100644 --- a/core/unix/loader.c +++ b/core/unix/loader.c @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2011-2023 Google, Inc. All rights reserved. + * Copyright (c) 2011-2024 Google, Inc. All rights reserved. * Copyright (c) 2011 Massachusetts Institute of Technology All rights reserved. * *******************************************************************************/ @@ -157,7 +157,7 @@ static privmod_t * privload_locate_and_load(const char *impname, privmod_t *dependent, bool reachable); static void -privload_call_lib_func(fp_t func); +privload_call_lib_func(dcontext_t *dcontext, privmod_t *privmod, fp_t func); static void privload_relocate_mod(privmod_t *mod); @@ -618,7 +618,7 @@ privload_call_entry(dcontext_t *dcontext, privmod_t *privmod, uint reason) if (opd->init != NULL) { LOG(GLOBAL, LOG_LOADER, 4, "%s: calling %s init func " PFX "\n", __FUNCTION__, privmod->name, opd->init); - privload_call_lib_func(opd->init); + privload_call_lib_func(dcontext, privmod, opd->init); } if (opd->init_array != NULL) { uint i; @@ -626,7 +626,7 @@ privload_call_entry(dcontext_t *dcontext, privmod_t *privmod, uint reason) if (opd->init_array[i] != NULL) { /* be paranoid */ LOG(GLOBAL, LOG_LOADER, 4, "%s: calling %s init array func " PFX "\n", __FUNCTION__, privmod->name, opd->init_array[i]); - privload_call_lib_func(opd->init_array[i]); + privload_call_lib_func(dcontext, privmod, opd->init_array[i]); } } } @@ -648,7 +648,7 @@ privload_call_entry(dcontext_t *dcontext, privmod_t *privmod, uint reason) if (opd->fini != NULL) { LOG(GLOBAL, LOG_LOADER, 4, "%s: calling %s fini func " PFX "\n", __FUNCTION__, privmod->name, opd->fini); - privload_call_lib_func(opd->fini); + privload_call_lib_func(dcontext, privmod, opd->fini); } if (opd->fini_array != NULL) { uint i; @@ -656,7 +656,7 @@ privload_call_entry(dcontext_t *dcontext, privmod_t *privmod, uint reason) if (opd->fini_array[i] != NULL) { /* be paranoid */ LOG(GLOBAL, LOG_LOADER, 4, "%s: calling %s fini array func " PFX "\n", __FUNCTION__, privmod->name, opd->fini_array[i]); - privload_call_lib_func(opd->fini_array[i]); + privload_call_lib_func(dcontext, privmod, opd->fini_array[i]); } } } @@ -1064,7 +1064,7 @@ get_private_library_address(app_pc modbase, const char *name) } static void -privload_call_lib_func(fp_t func) +privload_call_lib_func(dcontext_t *dcontext, privmod_t *privmod, fp_t func) { char dummy_str[] = "dummy"; char *dummy_argv[2]; @@ -1076,7 +1076,12 @@ privload_call_lib_func(fp_t func) */ dummy_argv[0] = dummy_str; dummy_argv[1] = NULL; - func(1, dummy_argv, our_environ); + TRY_EXCEPT_ALLOW_NO_DCONTEXT( + dcontext, { func(1, dummy_argv, our_environ); }, + { /* EXCEPT */ + SYSLOG_INTERNAL_ERROR("Private library %s init/fini func " PFX " crashed", + privmod->name, func); + }); } bool diff --git a/core/vmareas.c b/core/vmareas.c index 7ce19f0c85e..9658dde7690 100644 --- a/core/vmareas.c +++ b/core/vmareas.c @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright (c) 2010-2023 Google, Inc. All rights reserved. + * Copyright (c) 2010-2024 Google, Inc. All rights reserved. * Copyright (c) 2002-2010 VMware, Inc. All rights reserved. * **********************************************************/ @@ -8385,7 +8385,7 @@ check_in_last_thread_vm_area(dcontext_t *dcontext, app_pc pc) data->last_area->start <= pc); } /* last decoded app pc may be in last shared area instead */ - if (!in_last && DYNAMO_OPTION(shared_bbs)) { + if (!in_last && DYNAMO_OPTION(shared_bbs) && shared_data != NULL) { /* We avoid the high-ranked shared_vm_areas lock which can easily cause * rank order violations (i#3346). We're trying to catch the scenario * where a shared bb is being built and we fault decoding it. There,