-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remove O1 from sanitizer feature flag defaults #17355
Remove O1 from sanitizer feature flag defaults #17355
Conversation
cc: @brentleyjones |
@chiragramani I can't reproduce this on Linux with clang 14. What is your setup? Given that |
But can't you add |
@brentleyjones Sorry, I somehow thought this would add If the C++ toolchain framework supports it, we could add flags we know work well depending on the build mode, but that's a separate effort. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oquenchil Could you review?
@bazel-io flag |
@chiragramani Could you also remove the |
Thanks for reviewing it, updated the PR. |
@bazel-io fork 6.1.0 |
This PR removes `-O1` from the current set of sanitizer related feature flags defaults. **Context and Repro** 1. Heap buffer overflow in the following code block is not caught by asan. example.cc ``` #include <cstdlib> int main(int argc, char **argv) { int *array = new int[100]; array[0] = 0; int res = array[argc + 100]; // BOOM delete [] array; return res; } ``` BUILD ``` cc_binary( name = 'example', srcs = ['example.cc'], features = ['asan'], ) ``` execute: ``` bazel run :example ``` **Expectation:** Address sanitizer should detect and report heap buffer overflow. But this doesn't happen in the above case. It is because of O1 being applied by default and since this is added at the last, it also overrides explicit copts passed(O0). It would be nice if the optimization level is a bit de-coupled from the default group here. Closes #17355. PiperOrigin-RevId: 507658773 Change-Id: I3aa4fb92a2dc271cbbedfc6f05e72a8a9b2aba09 Co-authored-by: Chirag Ramani <chirag.ramani7@gmail.com>
This PR removes `-O1` from the current set of sanitizer related feature flags defaults. **Context and Repro** 1. Heap buffer overflow in the following code block is not caught by asan. example.cc ``` #include <cstdlib> int main(int argc, char **argv) { int *array = new int[100]; array[0] = 0; int res = array[argc + 100]; // BOOM delete [] array; return res; } ``` BUILD ``` cc_binary( name = 'example', srcs = ['example.cc'], features = ['asan'], ) ``` execute: ``` bazel run :example ``` **Expectation:** Address sanitizer should detect and report heap buffer overflow. But this doesn't happen in the above case. It is because of O1 being applied by default and since this is added at the last, it also overrides explicit copts passed(O0). It would be nice if the optimization level is a bit de-coupled from the default group here. Closes #17355. PiperOrigin-RevId: 507658773 Change-Id: I3aa4fb92a2dc271cbbedfc6f05e72a8a9b2aba09
This PR removes
-O1
from the current set of sanitizer related feature flags defaults.Context and Repro
example.cc
BUILD
execute:
Expectation:
Address sanitizer should detect and report heap buffer overflow.
But this doesn't happen in the above case. It is because of O1 being applied by default and since this is added at the last, it also overrides explicit copts passed(O0). It would be nice if the optimization level is a bit de-coupled from the default group here.