Skip to content

Bazel 0.16.0 crashes with StackOverflow on Windows #5730

Closed

Description

@philwo

After upgrading our Buildkite VMs to Bazel 0.16.0, we noticed that Bazel reproducibly crashes with a StackOverflow a few seconds after it starts building:

https://buildkite.com/bazel/bazel-bazel/builds/3702#a46f7545-e15e-4eca-bee2-904709ee4fed

I managed to repro this manually on the Windows VM and grabbed the jvm.out log:

Can't load log handler "java.util.logging.FileHandler"
java.nio.file.NoSuchFileException: c:users\philwo\_bazel~1\ozmjprom\java.log.lck
java.nio.file.NoSuchFileException: c:users\philwo\_bazel~1\ozmjprom\java.log.lck
	at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.newFileChannel(Unknown Source)
	at java.base/java.nio.channels.FileChannel.open(Unknown Source)
	at java.base/java.nio.channels.FileChannel.open(Unknown Source)
	at java.logging/java.util.logging.FileHandler.openFiles(Unknown Source)
	at java.logging/java.util.logging.FileHandler.<init>(Unknown Source)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.base/java.lang.Class.newInstance(Unknown Source)
	at java.logging/java.util.logging.LogManager.createLoggerHandlers(Unknown Source)
	at java.logging/java.util.logging.LogManager.access$1300(Unknown Source)
	at java.logging/java.util.logging.LogManager$4.run(Unknown Source)
	at java.logging/java.util.logging.LogManager$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.logging/java.util.logging.LogManager.loadLoggerHandlers(Unknown Source)
	at java.logging/java.util.logging.LogManager.initializeGlobalHandlers(Unknown Source)
	at java.logging/java.util.logging.LogManager.access$1800(Unknown Source)
	at java.logging/java.util.logging.LogManager$RootLogger.accessCheckedHandlers(Unknown Source)
	at java.logging/java.util.logging.Logger.getHandlers(Unknown Source)
	at java.logging/java.util.logging.Logger.log(Unknown Source)
	at java.logging/java.util.logging.Logger.doLog(Unknown Source)
	at java.logging/java.util.logging.Logger.log(Unknown Source)
	at java.logging/java.util.logging.Logger.info(Unknown Source)
	at com.google.devtools.build.lib.analysis.BlazeVersionInfo.logVersionInfo(BlazeVersionInfo.java:64)
	at com.google.devtools.build.lib.analysis.BlazeVersionInfo.setBuildInfo(BlazeVersionInfo.java:79)
	at com.google.devtools.build.lib.bazel.Bazel.main(Bazel.java:65)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/C:/Users/philwo/_bazel_philwo/install/d522db92d7621d404f960f24e49d0696/_embedded_binaries/A-server.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.StackOverflowError
	at java.base/java.util.concurrent.FutureTask.finishCompletion(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.set(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	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)
Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "Command-Accumulator-Thread-19"

@buchgr and my theory is that it must be caused by one of the last three cherry-picks that went into 0.16.0, because apparently 0.16.0rc3 was tested with downstream projects (which should have showed this issue), but 0.16.0rc4 (which became the final version) wasn't:

https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds?branch=release-0.16.0

Activity

  1. added
    P0
    on Aug 1, 2018
  2. philwo commented on Aug 1, 2018

    @philwo
    MemberAuthor
  3. laszlocsomor commented on Aug 1, 2018

    @laszlocsomor
    Contributor

    The problem seems to be a bad path, see the 2nd line of your log:

    java.nio.file.NoSuchFileException: c:users\philwo\_bazel~1\ozmjprom\java.log.lck
    

    The backslash is missing after "c:". I'll look into it.

  4. laszlocsomor commented on Aug 1, 2018

    @laszlocsomor
    Contributor

    Haha, never mind, that has nothing to do with the StackOverflow :)

  5. 9 remaining items

  6. philwo commented on Aug 8, 2018

    @philwo
    MemberAuthor

    @meteorcloudy I don't think that commit is in Bazel 0.16.0 (it uses OpenJDK 9), though?

  7. meteorcloudy commented on Aug 8, 2018

    @meteorcloudy
    Member

    @philwo You are right

  8. meteorcloudy commented on Aug 8, 2018

    @meteorcloudy
    Member

    I'm running bisect from 0.15.2's base commit to 0.16.0's base commit. It will take some time.

  9. buchgr commented on Aug 8, 2018

    @buchgr
    Contributor

    @meteorcloudy if you want to rule out that the JDK9 is at fault, please use #5786 which is the 0.16.0 code base with JDK8.

  10. meteorcloudy commented on Aug 8, 2018

    @meteorcloudy
    Member

    @buchgr Are we using JDK9 in 0.15.2?

  11. buchgr commented on Aug 8, 2018

    @buchgr
    Contributor
  12. buchgr commented on Aug 8, 2018

    @buchgr
    Contributor

    The error seems to always happen in a Command-Accumulator-Thread-* thread. Looking at the code, we specifically limit the stack size of these threads to 32 KiB (presumably to lower the memory consumption). Now, the default stack size on 64-bit windows is 1 MiB [1]. I think if @meteorcloudy finds the JDK9 change to be at fault, then a likely explanation is the implementation of the thread pool changed and now requires more than 32 KiB in stack size.

    [1] http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#threads_oom

  13. meteorcloudy commented on Aug 8, 2018

    @meteorcloudy
    Member

    I have confirmed it didn't fail on #5786, testing a possible fix suggested by @buchgr

  14. c-parsons commented on Aug 8, 2018

    @c-parsons
    Contributor

    I'm a little unclear on the root cause here -- do we anticipate this is a JDK9 issue that would be fixed by the commits in #5760 ?

  15. cushon commented on Aug 8, 2018

    @cushon
    Contributor

    @c-parsons no, I think this is unrelated to #5760.

  16. meteorcloudy commented on Aug 9, 2018

    @meteorcloudy
    Member

    @c-parsons Yes, this issue is gone if we revert JDK version to 8. But @buchgr has figured out a fix to make it work with JDK9 as well. I was running a test for a Bazel version of 0.16.0 with his fix all night, it didn't fail after 100 times rerun.

    #5760 is irrelevant to this issue, I'm ccing you in the internal CL for fixing this.

  17. added a commit that references this issue on Aug 9, 2018
    b9c5065
  18. added a commit that references this issue on Aug 13, 2018
    1bd5883
  19. added a commit that references this issue on Sep 12, 2018
    b3cc772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P0breakagecategory: misc > miscplatform: windowstype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions