From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B26DB3858C2C; Thu, 23 Dec 2021 04:05:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B26DB3858C2C From: "chefmax at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 6.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chefmax at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: chefmax at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Dec 2021 04:05:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D84250 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/upda= tes. Meanwhile, I found the reason why option 1) was reverted (explained by Jaku= b): 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 any= way > if you link one library with -fsanitize=3Dundefined and another library > with -fsanitize=3Daddress, 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 LL= VM 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 leng= th) { } StaticSpinMutex report_file_mu; -ReportFile report_file =3D {&report_file_mu, kStderrFd, "", "", 0}; +SANITIZER_INTERFACE_ATTRIBUTE ReportFile report_file =3D {&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_di= r); CommonInit();=