-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-fsanitize=address causes huge runtime slowdown from std::rethrow_exception not called #64190
Comments
Motivation is https://github.com/boostorg/exception/blob/b039b4ea18ef752d0c1684b3f715ce493b778060/include/boost/exception/detail/exception_ptr.hpp#L550 ; the half-reduced code is: #include <boost/exception_ptr.hpp>
struct S {};
int main() {
auto ep = boost::copy_exception(S());
for (int i = 0; i != 100000; ++i)
try { boost::rethrow_exception(ep); } catch (...) {}
} |
Bisected to 4b4437c (found initial bad commit from bisecting gcc)
|
By default -fsanitize=address already compiles with this check, why not use it. For compatibly it can be disabled with env ASAN_OPTIONS=detect_stack_use_after_return=0. Reviewed By: eugenis, kda, #sanitizers, hans Differential Revision: https://reviews.llvm.org/D124057
Assuming example is quite artificial, it has less value than However it's worth of investigation, maybe we can improve performance here easily. |
In case you need a bigger non-artificial example perhaps https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112981 is better? |
hi @vitalybuka! Did you worked on this? I'm new to llvm and planing to work on it and was hoping if you can give any general advice or guidance for me on how to kick-start my journey into solving this problem, I’d be grateful for the assistance. Thanks in advance! |
I didn't look into that. I guess you need to start with building LLVM and reproducing the issue with just built LLVM. |
Thanks. I'll let you know if I get to somewhere or face any issue :) |
@vitalybuka Hi! I've tried recreating the issue again but having some issues.
I've used 2 codes, the given example above and a random example. In both examples, I'm experiencing almost similar results i.e., same cycles reported by callgrind and almost similar slowdown introduced by the flag |
@vitalybuka the issue isn't the compile time to generate the object file / executable, but the runtime of the executable. |
This slowdown disappears when I export |
Compiled with -fsanitize=address (and at -O0 through -O3, for gcc), this is roughly 30x slower under gcc 13 than under gcc 12 (4.7s vs 0.15s on my Core i7 3 GHz).
On godbolt with clang/libc++ and clang/libstdc++ both the problem exhibits between clang 14.0.0 and clang 15.0.0. At -O1 clang appears capable of enough elision to reduce the impact somewhat (so it is only ~15x slower) and at -O3 to eliminate the bug entirely.
Initially reported to gcc at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110835 but they pointed out that it appears to be a bug in compiler-rt/asan, not in gcc/clang codegen.
Note that the std::rethrow_exception() is not called, but is still essential to exhibit the bug. Also
f
needs to be a separate function (and notstatic
). At low optimization levels it can be an iife.The text was updated successfully, but these errors were encountered: