This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common] Remove hacks for __builtin_return_address abuse on SPARC
ClosedPublic

Authored by ro on Jul 27 2023, 10:53 PM.

Details

Summary

As detailed in Issue #57624, the introduction of __builtin_extract_return_address to GET_CALLER_PC in 4248f32b9ebe87c7af8ee53911efd47c2652f488 broke TestCases/Misc/missing_return.cpp on Solaris/SPARC. Unlike most other targets, the builtin isn't a no-op on SPARC and thus has always been necessary. Its lack had previously been worked around by calls to GetNextInstructionPc in sanitizer_stacktrace_sparc.cpp (BufferedStackTrace::UnwindFast) and sanitizer_unwind_linux_libcdep.cpp (BufferedStackTrace::UnwindSlow). However, those calls are superfluous now and actually harmful.

This patch removes those hacks, fixing the failure.

Tested on sparcv9-sun-solaris2.11 and on sparc-sun-solaris2.11 in the GCC tree. On the latter, several more testcase failures had been caused by this issue since ASan actually works with gcc on SPARC, unlike clang.

Diff Detail

Event Timeline

ro created this revision.Jul 27 2023, 10:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 10:53 PM
ro requested review of this revision.Jul 27 2023, 10:53 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptJul 27 2023, 10:53 PM
ro added a reviewer: jrtc27.Aug 3 2023, 5:05 AM

Ping? It's been almost a week and the bug is a regression from LLVM 16. Thus it would be good to get the patch into the LLVM 17 release. Thanks.

jrtc27 accepted this revision.Aug 3 2023, 6:58 AM

Seems reasonable if tested. OOI is there a major reason ASan doesn’t work with Clang other than that the Sparc backend is a bit unloved?

This revision is now accepted and ready to land.Aug 3 2023, 6:58 AM
ro added a comment.Aug 3 2023, 7:05 AM

Seems reasonable if tested. OOI is there a major reason ASan doesn’t work with Clang other than that the Sparc backend is a bit unloved?

There's SPARC lacks support for over-aligned dynamic alloca. That Issue has been closed, however only the part breaking the test-suite build. has been fixed (or rather avoided by disabling the affected test. The underlying issue is still unfixed.