Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException raised with --target_pattern_file #23464

Open
ghost opened this issue Aug 29, 2024 · 1 comment
Open

ArrayIndexOutOfBoundsException raised with --target_pattern_file #23464

ghost opened this issue Aug 29, 2024 · 1 comment
Assignees
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug

Comments

@ghost
Copy link

ghost commented Aug 29, 2024

Description of the bug:

If the file given in the --target_pattern_file option contains an empty comment line, the command bazel build crashes with this exception below:

$ hexdump -C targets.list
00000000  23 0a                                             |#.|
00000002

$ bazel build --target_pattern_file=targets.list
...
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at com.google.devtools.build.lib.runtime.commands.TargetPatternsHelper.lambda$readFrom$0(TargetPatternsHelper.java:61)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
	at java.base/java.util.Collections$2.tryAdvance(Unknown Source)
	at java.base/java.util.Collections$2.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at com.google.devtools.build.lib.runtime.commands.TargetPatternsHelper.readFrom(TargetPatternsHelper.java:64)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:69)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:664)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:644)
	at io.grpc.Context$1.run(Context.java:566)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

On the other hand, no problem with single space after the #.

$ hexdump -C targets.list
00000000  23 20 0a                                          |# .|
00000003

$ bazel build --target_pattern_file=targets.list
...
Your request is correct, but requested an empty set of targets. Nothing will be built.
INFO: Found 0 targets...
INFO: Elapsed time: 1.591s, Critical Path: 0.14s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

Which category does this issue belong to?

No response

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

No response

Which operating system are you running Bazel on?

linux/amd64

What is the output of bazel info release?

release 7.3.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 HEAD ?

No response

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

@satyanandak satyanandak added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Aug 29, 2024
@haxorz
Copy link
Contributor

haxorz commented Oct 10, 2024

Thank you for the very clear bug report. Skimming over the code history, this was probably introduced by #15903. Looks like that code doesn't handle this exact situation.

@haxorz haxorz added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug
Projects
None yet
Development

No branches or pull requests

5 participants