Deadlock in clinit for sun.nio.ch.Util/IOUtil

Jeremy Manson jeremymanson at google.com
Tue Aug 6 22:21:55 UTC 2013


FAO alanb, I suppose.

There's a deadlock in these classes.  Thread 1 owns the class lock on Util,
and is suspended waiting for IOUtil to finish its class init.  Thread 2
owns the class lock on IOUtil, and is suspended waiting for Util to finish
its class init.

    Thread 1 (Suspended)
      owns: Class<T> (sun.nio.ch.Util) (id=19)
      Util.load() line: 491
      EPollSelectorImpl.<clinit>() line: 201
      EPollSelectorProvider.openSelector() line: 36
      Selector.open() line: 227

    Thread 2 (Suspended)       waiting for: Class<T> (sun.nio.ch.Util)
(id=19)
        owned by: Thread [main] (Suspended)
      Util.load() line: 482
      IOUtil.<clinit>() line: 340
      PipeImpl.<init>(SelectorProvider) line: 42
      EPollSelectorProvider(SelectorProviderImpl).openPipe() line: 50
      Pipe.open() line: 150

We can eagerly do class init as a workaround, but that seems less than
ideal.  It looks easy enough to fix - just move the stuff in Util.load()
into IOUtil somewhere, and don't call back to Util from IOUtil.<clinit>.
 But I'll defer to the experts.

Thanks!

Jeremy



More information about the core-libs-dev mailing list