bazelbuild / bazelbuild/bazel

Runfiles::Create does not work with `.stripped` binary

Open
#15,578 9 comments 0 reactions 0 assignees View on GitHub
P4 team-Rules-CPP type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

### Description of the bug:

Creating a [`Runfiles`](https://github.com/bazelbuild/bazel/blob/master/tools/cpp/runfiles/runfiles_src.h) instance with `Runfiles::Create(argv[0], nullptr)` works within a `cc_binary(name = "foo", ...` if run as `bazel run :foo`, but if the `.stripped` target is used instead, the creation fails (and thows an exception): `bazel run :foo.stripped`.

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

Make a `cc_binary` with content like https://github.com/bazelbuild/bazel/blob/881fc800fdd76773a4b229a64673bc3b8feb9745/tools/cpp/runfiles/runfiles_src.h#L34-L37, then run the stripped binary, either via `bazel run`, or via `bazel build` and then call the binary directly.

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

Linux

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

release 5.1.1

### 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 master; git rev-parse HEAD` ?

_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

Research direction

Start with tools/cpp/runfiles/runfiles_src.h and reproduce the issue using a minimal cc_binary, comparing bazel run :foo with bazel run :foo.stripped or a directly built stripped binary. Trace why Runfiles::Create(argv[0], nullptr) throws for the stripped target; done means the same creation succeeds without an exception for both targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
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.