mirror of
https://github.com/plasma-umass/coz.git
synced 2024-09-11 04:55:25 +03:00
Handle NULL return value from dlopen
This commit is contained in:
parent
2ffc5b2798
commit
44d46432c4
7
coz
7
coz
@ -106,6 +106,9 @@ def _coz_run(args):
|
||||
if args.fixed_speedup != None:
|
||||
env['COZ_FIXED_SPEEDUP'] = str(args.fixed_speedup)
|
||||
|
||||
if args.debug_libraries:
|
||||
env['LD_DEBUG'] = 'libs'
|
||||
|
||||
try:
|
||||
result = subprocess.call(args.remaining_args, env=env)
|
||||
except KeyboardInterrupt:
|
||||
@ -185,6 +188,10 @@ _run_parser.add_argument('--fixed-speedup',
|
||||
type=int, choices=list(range(0, 101)), default=None,
|
||||
help='Evaluate optimizations of a specific amount')
|
||||
|
||||
_run_parser.add_argument('--debug-libraries',
|
||||
action='store_true', default=False,
|
||||
help='Debug shared libraries (LD_DEBUG=libs)')
|
||||
|
||||
# Use defaults to recover handler function and parser object from parser output
|
||||
_run_parser.set_defaults(func=_coz_run, parser=_run_parser)
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "real.h"
|
||||
#include "ccutil/log.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
@ -37,6 +38,7 @@ static void* pthread_handle = NULL; //< The `dlopen` handle to libpthread
|
||||
static void* get_pthread_handle() {
|
||||
if(pthread_handle == NULL && !__atomic_exchange_n(&in_dlopen, true, __ATOMIC_ACQ_REL)) {
|
||||
pthread_handle = dlopen("libpthread.so.0", RTLD_NOW | RTLD_GLOBAL);
|
||||
REQUIRE(pthread_handle != NULL) << dlerror();
|
||||
__atomic_store_n(&in_dlopen, false, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user