From 35e0f55ad81fa8430f9f8da602d969d42492998f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Sun, 2 Apr 2023 19:44:19 +0200 Subject: [PATCH] ASan: Run with verify_asan_link_order=0 Avoids error message: ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. Affected tests: nested_detach nested_detach_kill nested_detach_kill_stuck nested_detach_stop nested_detach_wait --- src/RecordSession.cc | 3 +++ src/util.cc | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/RecordSession.cc b/src/RecordSession.cc index c419c185d81..e97d8f3fbcc 100644 --- a/src/RecordSession.cc +++ b/src/RecordSession.cc @@ -2223,6 +2223,8 @@ static ExeInfo read_exe_info(const string& exe_file) { ElfFileReader reader(fd); ret.arch = reader.arch(); + // Don't try to modifiy LD_PRELOAD when rr itself is built with ASan +#ifndef __SANITIZE_ADDRESS__ DynamicSection dynamic = reader.read_dynamic(); for (auto& entry : dynamic.entries) { if (entry.tag == DT_NEEDED && entry.val < dynamic.strtab.size()) { @@ -2236,6 +2238,7 @@ static ExeInfo read_exe_info(const string& exe_file) { } } } +#endif auto syms = reader.read_symbols(".dynsym", ".dynstr"); for (size_t i = 0; i < syms.size(); ++i) { diff --git a/src/util.cc b/src/util.cc index 059fd660530..f52d548d56d 100644 --- a/src/util.cc +++ b/src/util.cc @@ -2461,6 +2461,10 @@ int __lsan_is_turned_off(void) { return rr_lsan_is_turned_off; } +#include +const char *__asan_default_options() { + return "verify_asan_link_order=0"; +} #endif bool coredumping_signal_takes_down_entire_vm() {