bazelbuild / bazelbuild/bazel

Starlark CPU profile isn't written when Bazel is interrupted

Open
#28,154 1 comment 0 reactions 1 assignee Claimed by @katre View on GitHub
team-Starlark-Integration type: bug undecided
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

While debugging https://github.com/dzbarsky/rules_rs/issues/14, I wanted to capture a Starlark profile and see where the Rust aspect is getting stuck. Unfortunately, since Bazel hangs, the CPU profile is never fully stopped and no profile is written.

The profile is started [in `BlazeCommandDispatcher.execExclusively`](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java;drc=92d426e8ecdb6e947aa47907a114693b1a06cffd;l=438). The current code [stops the profile later in the same method](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java;drc=92d426e8ecdb6e947aa47907a114693b1a06cffd;l=761), but I assume the interruption is causing an earlier exit.

Bazel should trap that exception and stop the profile (writing out in-progress data).

### Which category does this issue belong to?

Starlark Integration

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

Follow the repro from https://github.com/dzbarsky/rules_rs/issues/14, adding `--starlark_cpu_profile=/tmp//tmp/rs_aspect.pprof`, and then hit ctrl-c three times once bazel reaches the "no actions running" state and hangs.

### Which operating system are you running Bazel on?

_No response_

### What is the output of `bazel info release`?

_No response_

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text

```

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.