bazelbuild / bazelisk

A user-friendly launcher for Bazel.
Apache License 2.0
1.95k stars 300 forks source link

bazelisk run/test hide segmentation violations #556

Open andrej-eisfeld opened 4 months ago

andrej-eisfeld commented 4 months ago

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

#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