bazelbuild / bazelbuild/bazelisk

bazelisk run/test hide segmentation violations

Open
#556 1 comment 0 reactions 0 assignees View on GitHub
help wanted P2 type:bug
Dominant language
Go
Stars
2.7k
Forks
424
PR merge metrics
No merged PRs in 30d

Description

### 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
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](https://github.com/bazelbuild/bazel/assets/55919036/f6e62f83-fa29-409b-bd07-0801d785495b)
![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)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with `bazelisk run` and compare its exit status and shell output with running the binary from `bazel-bin`. Trace the `bazelisk run` and `bazelisk test` entry points where process termination status is handled. Done means signal-based failures preserve the segmentation-violation status and message instead of becoming exit code 255.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.