-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from firedancer-io/ll/LD_PRELOAD-for-asan-exec…
…-insrt ASAN - if we fail to load a library with the subcommand exec-instr try again
- Loading branch information
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |