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 with internal error when building cc_binary #14548

Closed
Tracked by #17103
graywolf-at-work opened this issue Jan 11, 2022 · 15 comments
Closed
Tracked by #17103

Bazel crashes with internal error when building cc_binary #14548

graywolf-at-work opened this issue Jan 11, 2022 · 15 comments
Labels
more data needed P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@graywolf-at-work
Copy link
Contributor

Description of the problem / feature request:

I decided to give bazel a try and wanted to build a cc_binary. However bazel crashes with:

+   $ bazel build //:foo
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:foo (15 packages loaded, 57 targets configured).
INFO: Found 1 target...
[0 / 3] checking cached actions
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
        at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:118)
        at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:111)
        at com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction$ParamFileWriter.writeOutputFile(ParameterFileWriteAction.java:175)
        at com.google.devtools.build.lib.exec.FileWriteStrategy.beginWriteOutputToFile(FileWriteStrategy.java:58)
        at com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction.beginExecution(AbstractFileWriteAction.java:66)
        at com.google.devtools.build.lib.actions.Action.execute(Action.java:127)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:855)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1016)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:975)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:129)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:81)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:472)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:834)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:307)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @6a28ffa4
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
        at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:75)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.initInstance(StringUnsafe.java:56)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:37)
        ... 19 more

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

+$ ls -1
BUILD
main.c
WORKSPACE
+$ cat BUILD
cc_binary(
    name = "foo",
    srcs = ["main.c"],
)
+$ cat main.c
int
main(int argc, char **argv)
{
}
+$ cat WORKSPACE
workspace(name = "foobar")
+$ bazel build //:foo
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:foo (15 packages loaded, 57 targets configured).
INFO: Found 1 target...
[0 / 6] 3 actions, 0 running
    [Prepa] BazelWorkspaceStatusAction stable-status.txt
    [Prepa] Writing file foo-2.params
    [Prepa] Creating source manifest for //:foo
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
        at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:118)
        at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:111)
        at com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction$ParamFileWriter.writeOutputFile(ParameterFileWriteAction.java:175)
        at com.google.devtools.build.lib.exec.FileWriteStrategy.beginWriteOutputToFile(FileWriteStrategy.java:58)
        at com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction.beginExecution(AbstractFileWriteAction.java:66)
        at com.google.devtools.build.lib.actions.Action.execute(Action.java:127)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:855)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1016)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:975)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:129)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:81)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:472)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:834)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:307)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @c267ef4
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
        at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:75)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.initInstance(StringUnsafe.java:56)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:37)
        ... 19 more

What operating system are you running Bazel on?

Up to date archlinux.

+   $ uname -a
Linux wsshowmax 5.10.89-1-lts #1 SMP Sun, 02 Jan 2022 19:43:44 +0000 x86_64 GNU/Linux

What's the output of bazel info release?

+$ bazel info release
Starting local Bazel server and connecting to it...
release 4.2.2

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

+$ git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Have you found anything relevant by searching the web?

No.

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

No, I don't know much about bazel (yet), so I do not know what would be useful. However I'm happy to provide any necessary information if requested.

@oquenchil oquenchil added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged labels Jan 11, 2022
@oquenchil
Copy link
Contributor

Seems like an encoding problem.

@graywolf-at-work
Copy link
Contributor Author

I've tried it in fresh container and it works there. So it might be caused by
something on my host. However I have no idea by what. I've tried setting all my
env variables in the container and it still worked. Any ideas how to debug this
further?

+   $ podman run -it --rm --mount type=bind,src=$(pwd),dst=/x,ro docker.io/library/archlinux bash -c 'set -eu
yes | pacman -Syyu bazel gcc >/dev/null 2>&1
useradd -m foo
su - foo -c "cp -rv /x y && cd y && bazel build //:foo"'
'/x' -> 'y'
'/x/WORKSPACE' -> 'y/WORKSPACE'
'/x/BUILD' -> 'y/BUILD'
'/x/main.c' -> 'y/main.c'
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:foo (15 packages loaded, 57 targets configured).
INFO: Found 1 target...
Target //:foo up-to-date:
  bazel-bin/foo
INFO: Elapsed time: 6.018s, Critical Path: 0.12s
INFO: 6 processes: 4 internal, 2 processwrapper-sandbox.
INFO: Build completed successfully, 6 total actions

@potuz
Copy link

potuz commented Jan 18, 2022

Can reproduce this also on Arch, opened https://bugs.archlinux.org/task/73407 since it may well be a default configuration in Arch linux.

@potuz
Copy link

potuz commented Jan 19, 2022

As noticed in the Arch tracker by loqs, the issue in my case was the wrong java version chosen as default, if the OP confirms this may be closed

@graywolf-at-work
Copy link
Contributor Author

Yep, same here. sudo archlinux-java set java-11-openjdk resolved the issue
for me. However it is bit sad that the original error message was not very
helpful. Could bazel detect if it is running with the right java and if not,
die with a reasonable error message?

@fweikert fweikert added P1 I'll work on this now. (Assignee required) P2 We'll consider working on this in future. (Assignee optional) and removed untriaged P1 I'll work on this now. (Assignee required) labels Jan 24, 2022
@Tacodiva
Copy link

Tacodiva commented Mar 31, 2022

I'm running into this on Ubuntu. Using sudo update-alternatives --config java to set my /usr/bin/java to the java-11-openjdk does not solve the problem.
Just trying to build the 'stage1' main target from the 'Build a C++ Project' tutorial :(

@graywolf-at-work
Copy link
Contributor Author

Shouldn't it be java-11-openjdk?

@Tacodiva
Copy link

Tacodiva commented Apr 2, 2022

Sorry yes that is what I meant. I have updated my comment.

@sgowroji
Copy link
Member

Hello @graywolf-at-work, Could you please verify the above issue with the latest Bazel release 5.2.0. Am not able to reproduce with the latest version. Thank you!

@Tacodiva
Copy link

Not graywolf, but for me updating to release just now 5.2.0 fixed the issue.

@sgowroji
Copy link
Member

Thank you for responding quickly. We are closing this issue now. Please feel free to reach us if you still have any queries w.r.t the above request. Thanks!

@rdong8
Copy link

rdong8 commented Feb 6, 2023

Still getting this issue on Fedora 37 with bazel 5.4.0 from the vbatts/bazel copr

@nrwahl2
Copy link

nrwahl2 commented Feb 13, 2023

Still getting this issue on Fedora 37 with bazel 5.4.0 from the vbatts/bazel copr

Same here

@sgowroji
Copy link
Member

Hi @nrwahl2 & @rdong8, Could you please create a new issue with complete information init. Thanks !!

@blackgnezdo
Copy link
Contributor

FWIW, I'm also seeing this reliably happen when trying to build Bazel 6.3.2 with jdk-17.0.9 on OpenBSD 7.4.

cd /usr/ports/pobj/bazel-6.3.2 && /usr/bin/env -i  EMBED_LABEL="6.3.2"  EXTRA_BAZEL_ARGS="--java_runtime_version=local_jdk_17 --tool_java_runtime_version=local_jdk_17 --host_javabase=@local_jdk//:jdk"  PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin"  JAVA_HOME=/usr/local/jdk-17  SOURCE_DATE_EPOCH="0"  /usr/local/bin/bash ./compile.sh
...
🍃  Building Bazel from scratch......
🍃  Building Bazel with Bazel.
.OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: Option 'host_javabase' is deprecated
...
[219 / 625] PythonZipper src/create_embedded_tools.zip [for tool]; 0s local
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
	at com.google.devtools.build.lib.actions.ParameterFile.writeContentLatin1(ParameterFile.java:141)
	at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:120)
	at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:112)
	at com.google.devtools.build.lib.actions.CommandLines$ParamFileActionInput.writeTo(CommandLines.java:319)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.start(LocalSpawnRunner.java:368)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.runOnce(LocalSpawnRunner.java:258)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.run(LocalSpawnRunner.java:229)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner.exec(LocalSpawnRunner.java:170)
	at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:301)
	at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
	at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
	at com.google.devtools.build.lib.actions.SpawnStrategy.beginExecution(SpawnStrategy.java:47)
	at com.google.devtools.build.lib.exec.SpawnStrategyResolver.beginExecution(SpawnStrategyResolver.java:64)
	at com.google.devtools.build.lib.analysis.actions.SpawnAction.beginExecution(SpawnAction.java:352)
	at com.google.devtools.build.lib.actions.Action.execute(Action.java:133)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:961)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1128)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1086)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:519)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:827)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:562)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1375)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @524667b
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
	at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:61)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:36)
	... 32 more

ERROR: Could not build Bazel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more data needed P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

9 participants