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.
Details
Diff Detail
- Build Status
Buildable 2541 Build 2541: arc lint + arc unit
Event Timeline
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. |
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. |
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).
lgtm, thanks! Eventually we should teach clang to pattern match assume(0) -> builtin_unreachable.
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. |
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.