public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "chefmax at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/84250] Symbol collision when using both Address and Undefined Behavior sanitizers (-fsanitize=address,undefined) Date: Thu, 23 Dec 2021 04:05:06 +0000 [thread overview] Message-ID: <bug-84250-4-j4qmvvHyhd@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-84250-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84250 chefmax at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |WAITING --- Comment #12 from chefmax at gcc dot gnu.org --- > If you're not planning to get back to this then I think it'd be good to > unassign. I don't know whom we would reassign this to at this point. Ok, I'm unassigning this now because I can't guarantee prompt reaction/updates. Meanwhile, I found the reason why option 1) was reverted (explained by Jakub): https://gcc.gnu.org/pipermail/gcc-patches/2018-July/501921.html > the 1) variant is actually not a good idea, it will not work properly anyway > if you link one library with -fsanitize=undefined and another library > with -fsanitize=address, the right solution is to make the two libraries > coexist sanely If we want to follow this way, we may need to introduce something like libsanitizer_common.so but this may also require pushing some patches in LLVM upstream. And just in case, let me post the variant 2) fix here, just to have a reference: diff --git a/libsanitizer/sanitizer_common/sanitizer_file.cpp b/libsanitizer/sanitizer_common/sanitizer_file.cpp index 5492560df91..c7013166ef6 100644 --- a/libsanitizer/sanitizer_common/sanitizer_file.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_file.cpp @@ -27,7 +27,8 @@ void CatastrophicErrorWrite(const char *buffer, uptr length) { } StaticSpinMutex report_file_mu; -ReportFile report_file = {&report_file_mu, kStderrFd, "", "", 0}; +SANITIZER_INTERFACE_ATTRIBUTE ReportFile report_file = {&report_file_mu, + kStderrFd, "", "", 0}; void RawWrite(const char *buffer) { report_file.Write(buffer, internal_strlen(buffer)); diff --git a/libsanitizer/sanitizer_common/sanitizer_file.h b/libsanitizer/sanitizer_common/sanitizer_file.h index 3d7916171c1..0ce1f417030 100644 --- a/libsanitizer/sanitizer_common/sanitizer_file.h +++ b/libsanitizer/sanitizer_common/sanitizer_file.h @@ -47,7 +47,7 @@ struct ReportFile { private: void ReopenIfNecessary(); }; -extern ReportFile report_file; +extern SANITIZER_INTERFACE_ATTRIBUTE ReportFile report_file; enum FileAccessMode { RdOnly, diff --git a/libsanitizer/ubsan/ubsan_init.cpp b/libsanitizer/ubsan/ubsan_init.cpp index 9931d85bf40..042026fee8d 100644 --- a/libsanitizer/ubsan/ubsan_init.cpp +++ b/libsanitizer/ubsan/ubsan_init.cpp @@ -43,7 +43,13 @@ static void CommonStandaloneInit() { CacheBinaryName(); InitializeFlags(); __sanitizer::InitializePlatformEarly(); - __sanitizer_set_report_path(common_flags()->log_path); + + // GCC-specific: in case of both ASan/UBSan runtimes are present, + // ASan or application itself may have aleady defined report path. + // Do not override it when initializing UBSan. + if (!__sanitizer_get_report_path()) { + __sanitizer_set_report_path(common_flags()->log_path); + } AndroidLogInit(); InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir); CommonInit();
next prev parent reply other threads:[~2021-12-23 4:05 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-84250-4@http.gcc.gnu.org/bugzilla/> 2021-05-04 12:31 ` rguenth at gcc dot gnu.org 2021-12-16 16:41 ` mpolacek at gcc dot gnu.org 2021-12-17 4:53 ` chefmax at gcc dot gnu.org 2021-12-17 14:14 ` mpolacek at gcc dot gnu.org 2021-12-23 4:05 ` chefmax at gcc dot gnu.org [this message] 2022-10-14 9:21 ` shanchuantian at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-84250-4-j4qmvvHyhd@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).