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

bazelisk run/test hide segmentation violations #556

Open
andrej-eisfeld opened this issue Feb 23, 2024 · 0 comments
Open

bazelisk run/test hide segmentation violations #556

andrej-eisfeld opened this issue Feb 23, 2024 · 0 comments
Labels
help wanted Needs help from external contributors P2 We'll consider working on this in future. (Assignee optional) type:bug Something isn't working

Comments

@andrej-eisfeld
Copy link

andrej-eisfeld commented Feb 23, 2024

Description of the bug:

bazelisk run hides segmentation violations, e.g. if "bazel run" returns with rc==139 "bazelisk run" will return with code 255 instead. Thus the shell also won't print the "segmentation violation" error.

Also see the discussion in the original ticket here for more details bazelbuild/bazel#21470

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

main.cc

#include <iostream>
using namespace std;
 
int main()
{
    char* str;
 
    // Stored in read only part of data segment //
    str = "GfG";
 
    // Problem:  trying to modify read only memory //
    *(str + 1) = 'n';
    return 0;
}

BUILD

cc_binary(
     name = "main",
     srcs = ["main.cc"],
)

When we "bazelisk run" the cc_binary here's what we get (note on the screenshot bazel is an alias for bazelisk):
image
image

Running the binary from bazel-bin instead we clearly see the application segfaults (return code 139)
image

@meteorcloudy meteorcloudy added type:bug Something isn't working help wanted Needs help from external contributors P2 We'll consider working on this in future. (Assignee optional) labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Needs help from external contributors P2 We'll consider working on this in future. (Assignee optional) type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants