This is an archive of the discontinued LLVM Phabricator instance.

fix warning about noreturn in sanitizer_win's internal__exit()
ClosedPublic

Authored by inglorion on Jan 3 2017, 5:22 PM.

Details

Summary

A previous fix used __assume(0), but not all compilers know that control will
not pass that. This patch uses a macro which works in more compilers.

Event Timeline

inglorion updated this revision to Diff 82979.Jan 3 2017, 5:22 PM
inglorion retitled this revision from to fix warning about noreturn in sanitizer_win's internal__exit().
inglorion updated this object.
inglorion added a reviewer: rnk.
rnk added inline comments.Jan 3 2017, 5:34 PM
lib/sanitizer_common/sanitizer_win.cc
41

We don't want to do that, because it can re-enter into internal__exit() and then it would stack overflow. Defining it to nothing is OK. It just means that compilers that are not gcc, clang, or msvc will have false positive warnings. TerminateProcess will never return.

Similarly, this is why we can't call sanitizer_common's normal UNREACHABLE macro. It would re-enter. I guess we could call ExitProcess or something that is marked noreturn, but it would run finalizers and that's bad.

inglorion added inline comments.Jan 4 2017, 11:51 AM
lib/sanitizer_common/sanitizer_win.cc
41

Right, I knew about UNREACHABLE re-entering, which is why I didn't just use that. I'll change the fallback implementation to be empty and add a comment with what you wrote so the next reader doesn't make the same mistake I did.

inglorion updated this revision to Diff 83112.Jan 4 2017, 1:14 PM

Removed code that terminates the process and added a comment explaining why such code is incorrect.

With this change, compiler-rt builds without warnings when lld is used as the linker (MSVC's link.exe still emits one warning because it doesn't support weak symbols).

rnk accepted this revision.Jan 4 2017, 4:22 PM
rnk edited edge metadata.

lgtm, thanks! Eventually we should teach clang to pattern match assume(0) -> builtin_unreachable.

This revision is now accepted and ready to land.Jan 4 2017, 4:22 PM
This revision was automatically updated to reflect the committed changes.
alekseyshl added inline comments.
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
40 ↗(On Diff #83166)

At least sanitizer-x86_64-linux-autoconf bot failed lib/CMakeFiles/SanitizerLintCheck with "Lines should be <= 80 characters long" error.