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.
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):
Running the binary from bazel-bin instead we clearly see the application segfaults (return code 139)
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 https://github.com/bazelbuild/bazel/issues/21470
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
main.cc
BUILD
When we "bazelisk run" the cc_binary here's what we get (note on the screenshot bazel is an alias for bazelisk):
![image](https://github.com/bazelbuild/bazel/assets/55919036/dbd4f1ed-a630-455e-85b6-99ae0ab7d813)
Running the binary from bazel-bin instead we clearly see the application segfaults (return code 139)![image](https://github.com/bazelbuild/bazel/assets/55919036/6dec67d2-85cc-4d16-97bd-3ca041233ffa)