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

Bazel crashes if piped to command that closes exits early #13616

Closed
v3n opened this issue Jun 26, 2021 · 1 comment
Closed

Bazel crashes if piped to command that closes exits early #13616

v3n opened this issue Jun 26, 2021 · 1 comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@v3n
Copy link

v3n commented Jun 26, 2021

Description of the problem / feature request:

Bazel crashed while unable to write to stdout. I would expect Bazel to close with an error instead of crashing, as the crashing behavior clears the analysis cache.

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

I reproduced it by piping an acquery call to a jq pipeline that failed with a syntax error.

bazel aquery --output=jsonproto 'outputs(".*", <snip>)' | jq '. | [ .actions.[].outputIds[] ]'

What operating system are you running Bazel on?

macOS 11.4

What's the output of bazel info release?

release 4.1.0

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

jq: error: syntax error, unexpected '[', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
. | [ .actions.[].outputIds[] ]               
jq: error: syntax error, unexpected ']', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
. | [ .actions.[].outputIds[] ]                              
jq: 2 compile errors
Starting local Bazel server and connecting to it...
INFO: Invocation ID: bdb56bbe-1ed6-4078-a9f3-7430635415f6
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
<SNIP>
INFO: Found 1 target...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_jhoward/6629d7ad2e07b93af304e686ea085d2a/sandbox

Cannot write to standard output; exiting...

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.AssertionError
	at com.google.devtools.build.lib.remote.ReferenceCountedChannel$1.deallocate(ReferenceCountedChannel.java:48)
	at io.netty.util.AbstractReferenceCounted.handleRelease(AbstractReferenceCounted.java:86)
	at io.netty.util.AbstractReferenceCounted.release(AbstractReferenceCounted.java:76)
	at com.google.devtools.build.lib.remote.ReferenceCountedChannel.release(ReferenceCountedChannel.java:144)
	at com.google.devtools.build.lib.remote.GrpcCacheClient.close(GrpcCacheClient.java:166)
	at com.google.devtools.build.lib.remote.disk.DiskAndRemoteCacheClient.close(DiskAndRemoteCacheClient.java:64)
	at com.google.devtools.build.lib.remote.RemoteCache.close(RemoteCache.java:1021)
	at com.google.devtools.build.lib.remote.RemoteActionContextProvider.executionPhaseEnding(RemoteActionContextProvider.java:154)
	at com.google.devtools.build.lib.buildtool.ExecutionTool.shutdown(ExecutionTool.java:229)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:245)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:408)
	at com.google.devtools.build.lib.runtime.commands.AqueryCommand.exec(AqueryCommand.java:136)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:579)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:231)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:543)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:606)
	at io.grpc.Context$1.run(Context.java:579)
	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)
Caused by: java.io.IOException
	at com.google.devtools.build.lib.remote.grpc.ChannelConnectionFactory$ChannelConnection.close(ChannelConnectionFactory.java:56)
	at com.google.devtools.build.lib.remote.grpc.SharedConnectionFactory.close(SharedConnectionFactory.java:75)
	at com.google.devtools.build.lib.remote.grpc.DynamicConnectionPool.close(DynamicConnectionPool.java:57)
	at com.google.devtools.build.lib.remote.ReferenceCountedChannel$1.deallocate(ReferenceCountedChannel.java:46)
	... 19 more
Caused by: java.lang.InterruptedException
	at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(Unknown Source)
	at java.base/java.util.concurrent.CountDownLatch.await(Unknown Source)
	at io.grpc.internal.ManagedChannelImpl.awaitTermination(ManagedChannelImpl.java:861)
	at io.grpc.internal.ForwardingManagedChannel.awaitTermination(ForwardingManagedChannel.java:57)
	at com.google.devtools.build.lib.remote.grpc.ChannelConnectionFactory$ChannelConnection.close(ChannelConnectionFactory.java:54)
	... 22 more
@aiuto aiuto added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged labels Jun 27, 2021
@coeuvre
Copy link
Member

coeuvre commented Jun 28, 2021

Duplicate of #13512. Fixed by #13521. The fix should be included in the coming release 4.2.0. Closing.

@coeuvre coeuvre closed this as completed Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
Development

No branches or pull requests

3 participants