diff --git a/.gitmodules b/.gitmodules index 393250f..0a488d0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,5 +11,5 @@ branch = agave-v2.0 [submodule "impl/solfuzz"] path = impl/solfuzz - url = https://github.com/firedancer-io/solfuzz + url = git@github.com:firedancer-io/solfuzz.git branch = main diff --git a/src/test_suite/test_suite.py b/src/test_suite/test_suite.py index 273c9d8..61fa40d 100644 --- a/src/test_suite/test_suite.py +++ b/src/test_suite/test_suite.py @@ -19,6 +19,7 @@ ) import test_suite.globals as globals from test_suite.debugger import debug_host +from test_suite.util import set_ld_preload_asan import resource import tqdm from test_suite.fuzz_context import ElfHarness, InstrHarness, SyscallHarness @@ -58,7 +59,10 @@ def exec_instr( # Initialize output buffers and shared library initialize_process_output_buffers(randomize_output_buffer=randomize_output_buffer) - lib = ctypes.CDLL(shared_library) + try: + lib = ctypes.CDLL(shared_library) + except: + set_ld_preload_asan() lib.sol_compat_init() # Execute and cleanup diff --git a/src/test_suite/util.py b/src/test_suite/util.py new file mode 100644 index 0000000..c6e2f21 --- /dev/null +++ b/src/test_suite/util.py @@ -0,0 +1,23 @@ +import subprocess +import os +import sys + + +def set_ld_preload_asan(): + # Run ldconfig -p and capture output + ldconfig_output = subprocess.check_output(["ldconfig", "-p"], text=True) + + # Filter lines containing "asan" + asan_libs = [line for line in ldconfig_output.split("\n") if "asan" in line] + + # Extract the first library path if available + if asan_libs: + first_asan_lib = asan_libs[0].split()[-1] + else: + print("No ASAN library found.") + return + + # Set LD_PRELOAD environment variable + os.environ["LD_PRELOAD"] = first_asan_lib + print(f"LD_PRELOAD set to {first_asan_lib}") + os.execvp(sys.argv[0], sys.argv)