Skip to content
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

Add an "asan" bazel config to debug crashes #28

Merged
merged 1 commit into from
Feb 15, 2022
Merged

Conversation

CodingCanuck
Copy link
Contributor

This allows you to build targets or tests with --config=asan and get
detailed debugging information for bad memory access.

Adding this in dev-tools so it can be easily shared across repos: we'll
use this a lot for any C++ development.

@benh
Copy link
Member

benh commented Feb 15, 2022

Ad discussed synchronously, let's add some comments here as to which permutation of compiler + operating system this is for, e.g., Linux + gcc or macOS + clang, etc.

Also dropping this in case it's helpful: https://github.com/envoyproxy/envoy/blob/main/.bazelrc#L62

@CodingCanuck
Copy link
Contributor Author

@onelxj Ben mentioned you might be interested in this.

Sample use of this PR: https://github.com/reboot-dev/respect/pull/69

@CodingCanuck
Copy link
Contributor Author

Ad discussed synchronously, let's add some comments here as to which permutation of compiler + operating system this is for, e.g., Linux + gcc or macOS + clang, etc.

Done (though I don't know if the bazel default is to compile with gcc or llvm/clang):

# As of 2020/02/15, this has been tested on linux with the bazel default C++
# compiler.

Also dropping this in case it's helpful: https://github.com/envoyproxy/envoy/blob/main/.bazelrc#L62

Thanks!

That does a lot of envoy-specific stuff, e.g.:

# ASAN install its signal handler, disable ours so the stacktrace will be printed by ASAN
build:asan --define signal_trace=disabled
build:asan --define ENVOY_CONFIG_ASAN=1

I'd be curious if the minimal asan config in this PR works across several environments, though I don't have any experience building / running on other OSs.

This allows you to build targets or tests with `--config=asan` and get
detailed debugging information for bad memory access.

Adding this in dev-tools so it can be easily shared across repos: we'll
use this a lot for any C++ development.
Copy link
Contributor

@rjhuijsman rjhuijsman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very excited about this! 🎉

@CodingCanuck CodingCanuck merged commit a3ead55 into main Feb 15, 2022
@CodingCanuck CodingCanuck deleted the alexmc.bazelrc branch February 15, 2022 23:25
CodingCanuck added a commit to 3rdparty/eventuals-grpc that referenced this pull request Feb 16, 2022
CodingCanuck added a commit to 3rdparty/eventuals that referenced this pull request Feb 16, 2022
CodingCanuck added a commit to 3rdparty/eventuals-grpc that referenced this pull request Feb 16, 2022
CodingCanuck added a commit to 3rdparty/eventuals that referenced this pull request Feb 16, 2022
@CodingCanuck
Copy link
Contributor Author

@benh you mentioned that there might be something like a built in --features=asan or similar: do you have any links about that? It doesn't work on my first try.

Specifically, this command (which relies on the new config introduced by this PR) produces an asan error about a stack-buffer-overflow when run in the respect repo:

dazel run --config=asan //test/object-store:test

Whereas this command runs, but doesn't produce any asan-like output:

dazel run --features=asan //test/object-store:test

Sample output:

[ RUN      ] ObjectStoreTest.Fill_BadIdFills
unknown file: Failure
Unknown C++ exception thrown in the test body.
[  FAILED  ] ObjectStoreTest.Fill_BadIdFills (7 ms)

@benh
Copy link
Member

benh commented Feb 21, 2022

I believe the --features=asan was first discovered here. But a little spelunking makes it look like this "feature" was only added for macOS? Maybe something for us to keep our eye on to see if it gets added in a more first-class capacity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants