Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8145888

java.nio.file.Files.find deadlock when using parallel stream

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS X 10.10.4 (14E46)

      A DESCRIPTION OF THE PROBLEM :
      When running such such code snippet:
      Files.find(dir, 30, (p, n) -> {
      return n.isRegularFile() && String.valueOf(p).endsWith(CLASS_EXT) );
      }, FileVisitOption.FOLLOW_LINKS)
      .parallel()
      .map(.........

      The system would hang intermittently. I am able to catch this situation in debug mode in eclipse to suspend the threads (which are already hanging) to see "where the are at the moment". Adding stack traces of original app in the 'Actual Results' section. When I run it in debug mode this situation happens scarcely. With normal mode on the other hand it is quite frequent.


      ACTUAL -
      I can see following traces:
      Daemon Thread [ForkJoinPool.commonPool-worker-1] (Suspended)
      waiting for: (id=38)
      707161353.test(Object, Object) line: not available
      Files.lambda$find$84(BiPredicate, FileTreeWalker$Event) line: 3691
      1864869682.test(Object) line: not available
      ReferencePipeline$2$1.accept(P_OUT) line: 174
      Spliterators$ArraySpliterator<T>.forEachRemaining(Consumer<? super T>) line: 948
      ReferencePipeline$3(AbstractPipeline<E_IN,E_OUT,S>).copyInto(Sink<P_IN>, Spliterator<P_IN>) line: 481
      ForEachOps$ForEachTask<S,T>.compute() line: 291
      ForEachOps$ForEachTask<S,T>(CountedCompleter<T>).exec() line: 731
      ForEachOps$ForEachTask<S,T>(ForkJoinTask<V>).doExec() line: 289
      ForkJoinPool$WorkQueue.runTask(ForkJoinTask<?>) line: 1056
      ForkJoinPool.runWorker(ForkJoinPool$WorkQueue) line: 1692
      ForkJoinWorkerThread.run() line: 157

      Thread [ReaderThread] (Suspended)
      owns: InputStreamReader (id=64)
      SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]
      SocketInputStream.socketRead(FileDescriptor, byte[], int, int, int) line: 116
      SocketInputStream.read(byte[], int, int, int) line: 170
      SocketInputStream.read(byte[], int, int) line: 141
      StreamDecoder.readBytes() line: 284
      StreamDecoder.implRead(char[], int, int) line: 326
      StreamDecoder.read(char[], int, int) line: 178
      InputStreamReader.read(char[], int, int) line: 184
      BufferedReader.fill() line: 161
      BufferedReader.readLine(boolean) line: 324
      BufferedReader.readLine() line: 389
      RemoteTestRunner$ReaderThread.run() line: 135

      Thread [main] (Suspended)
      waiting for: ForEachOps$ForEachTask<S,T> (id=88)
      Object.wait(long) line: not available [native method]
      ForEachOps$ForEachTask<S,T>(ForkJoinTask<V>).externalAwaitDone() line: 334
      ForEachOps$ForEachTask<S,T>(ForkJoinTask<V>).doInvoke() line: 405
      ForEachOps$ForEachTask<S,T>(ForkJoinTask<V>).invoke() line: 734
      ForEachOps$ForEachOp$OfRef<T>(ForEachOps$ForEachOp<T>).evaluateParallel(PipelineHelper<T>, Spliterator<S>) line: 160
      ForEachOps$ForEachOp$OfRef<T>.evaluateParallel(PipelineHelper, Spliterator) line: 174
      ReferencePipeline$3(AbstractPipeline<E_IN,E_OUT,S>).evaluate(TerminalOp<E_OUT,R>) line: 233
      ReferencePipeline$3(ReferencePipeline<P_IN,P_OUT>).forEach(Consumer<? super P_OUT>) line: 418
      ConnectionFactory.addPojosFromDirectory(Configuration, Path, Collection<String>) line: 73
      ConnectionFactory.lambda$2(Configuration, List, List, String) line: 51
      1750498848.accept(Object) line: not available
      Spliterators$ArraySpliterator<T>.forEachRemaining(Consumer<? super T>) line: 948
      ReferencePipeline$Head<E_IN,E_OUT>.forEach(Consumer<? super E_OUT>) line: 580
      ConnectionFactory.addPojosToConfig(Configuration, String...) line: 46
      ConnectionFactory.createFactory() line: 36
      ConnectionFactory.<clinit>() line: 24
      SessionPool.getSession() line: 18
      AbstractPojoTest<T,K>.beforeClass() line: 23
      NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
      NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
      Method.invoke(Object, Object...) line: 497
      FrameworkMethod$1.runReflectiveCall() line: 44
      FrameworkMethod$1(ReflectiveCallable).run() line: 15
      FrameworkMethod.invokeExplosively(Object, Object...) line: 41
      RunBefores.evaluate() line: 27
      RunAfters.evaluate() line: 31
      BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236
      JUnit4TestReference.run(TestExecution) line: 86
      TestExecution.run(ITestReference[]) line: 38
      RemoteTestRunner.runTests(String[], String, TestExecution) line: 459
      RemoteTestRunner.runTests(TestExecution) line: 675
      RemoteTestRunner.run() line: 382
      RemoteTestRunner.main(String[]) line: 192


      REPRODUCIBILITY :
      This bug can be reproduced occasionally.

      CUSTOMER SUBMITTED WORKAROUND :
      Making the stream sequential.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: