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

NullPointerException on extent-local variables

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      The problem arises in various environments:

      1) Windows 11 Pro: Version 21H2, OS build 22000.675
      PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 142 Stepping 11, GenuineIntel
      openjdk version "19-loom" 2022-09-20
      OpenJDK Runtime Environment (build 19-loom+6-625)
      OpenJDK 64-Bit Server VM (build 19-loom+6-625, mixed mode, sharing)

      2) Linux VOG 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
      /proc/cpuinfo:
      vendor_id : GenuineIntel
      cpu family : 6
      model : 142
      model name : Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
      stepping : 11
      microcode : 0xffffffff
      cpu MHz : 1992.007
      cache size : 8192 KB
      physical id : 0
      siblings : 8
      core id : 0
      cpu cores : 4
      apicid : 0
      initial apicid : 0
      fpu : yes
      fpu_exception : yes
      cpuid level : 22
      wp : yes
      flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid ept_ad fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities
      vmx flags : vnmi invvpid ept_x_only ept_ad ept_1gb tsc_offset vtpr ept vpid unrestricted_guest ept_mode_based_exec
      bugs : spectre_v1 spectre_v2 spec_store_bypass mds swapgs itlb_multihit srbds
      bogomips : 3984.01
      clflush size : 64
      cache_alignment : 64
      address sizes : 39 bits physical, 48 bits virtual
      openjdk 19-loom 2022-09-20
      OpenJDK Runtime Environment (build 19-loom+6-625)
      OpenJDK 64-Bit Server VM (build 19-loom+6-625, mixed mode, sharing)

      3) Linux fe3cbf72a8c1 5.4.188+ #1 SMP Sun Apr 24 10:03:06 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux
      /proc/cpuinfo:
      vendor_id : GenuineIntel
      cpu family : 6
      model : 79
      model name : Intel(R) Xeon(R) CPU @ 2.20GHz
      stepping : 0
      microcode : 0x1
      cpu MHz : 2199.998
      cache size : 56320 KB
      physical id : 0
      siblings : 2
      core id : 0
      cpu cores : 1
      apicid : 0
      initial apicid : 0
      fpu : yes
      fpu_exception : yes
      cpuid level : 13
      wp : yes
      flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat md_clear arch_capabilities
      bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa
      bogomips : 4399.99
      clflush size : 64
      cache_alignment : 64
      address sizes : 46 bits physical, 48 bits virtual
      power management:
      openjdk 19-loom 2022-09-20
      OpenJDK Runtime Environment (build 19-loom+6-625)
      OpenJDK 64-Bit Server VM (build 19-loom+6-625, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      I am exploring capabilites of the Loom project, in particular the StructuredTaskScope and ExtentLocal (JEP 425, JDK-8286666). I wrote a piece of code which is pretty similar to the example in JavaDocs on StructuredTaskScope. The code raises the following exception:

      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:65)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:53)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)

      Since the number of iterations before the error varies from launch to launch and depends on the N variable, I think that it could be a kind of data race on the extentLocalCache, or the actual value is lost during the context switch. If blocks (1) and (2) are swapped, the result is the same.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java --source 19 --enable-preview --add-modules jdk.incubator.concurrent ExtentLocalBreakingDemo.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Iteration 0
      OK
      Iteration 1
      OK
      ...
      Iteration 999
      OK
      ACTUAL -
      Iteration 0
      OK
      Iteration 1
      OK
      Iteration 2
      OK
      Iteration 3
      OK
      Iteration 4
      OK
      Iteration 5
      OK
      Iteration 6
      OK
      Iteration 7
      OK
      Iteration 8
      OK
      Iteration 9
      OK
      Iteration 10
      OK
      Iteration 11
      OK
      Iteration 12
      OK
      Iteration 13
      OK
      Iteration 14
      OK
      Iteration 15
      OK
      Iteration 16
      OK
      Iteration 17
      OK
      Iteration 18
      OK
      Iteration 19
      OK
      Iteration 20
      OK
      Iteration 21
      OK
      Iteration 22
      OK
      Iteration 23
      OK
      Iteration 24
      OK
      Iteration 25
      OK
      Iteration 26
      OK
      Iteration 27
      OK
      Iteration 28
      OK
      Iteration 29
      OK
      Iteration 30
      OK
      Iteration 31
      OK
      Iteration 32
      OK
      Iteration 33
      OK
      Iteration 34
      OK
      Iteration 35
      OK
      Iteration 36
      OK
      Iteration 37
      OK
      Iteration 38
      OK
      Iteration 39
      OK
      Iteration 40
      OK
      Iteration 41
      VirtualThread[#83972]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:52)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      VirtualThread[#84000]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:52)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      VirtualThread[#84021]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$2(ExtentLocalBreakingDemo.java:53)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      VirtualThread[#84037]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$2(ExtentLocalBreakingDemo.java:53)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      VirtualThread[#83981]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$2(ExtentLocalBreakingDemo.java:53)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      VirtualThread[#84008]/runnable@ForkJoinPool-1-worker-2
      java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:52)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      at ExtentLocalBreakingDemo.lambda$fill$0(ExtentLocalBreakingDemo.java:34)
      at java.base/jdk.internal.vm.ExtentLocalContainer.runWithoutScope(ExtentLocalContainer.java:114)
      at java.base/jdk.internal.vm.ExtentLocalContainer.run(ExtentLocalContainer.java:100)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Carrier.run(ExtentLocal.java:327)
      at ExtentLocalBreakingDemo.fill(ExtentLocalBreakingDemo.java:34)
      at ExtentLocalBreakingDemo.main(ExtentLocalBreakingDemo.java:18)
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      at ExtentLocalBreakingDemo.lambda$fill$0(ExtentLocalBreakingDemo.java:34)
      at java.base/jdk.internal.vm.ExtentLocalContainer.runWithoutScope(ExtentLocalContainer.java:114)
      at java.base/jdk.internal.vm.ExtentLocalContainer.run(ExtentLocalContainer.java:100)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Carrier.run(ExtentLocal.java:327)
      at ExtentLocalBreakingDemo.fill(ExtentLocalBreakingDemo.java:34)
      at ExtentLocalBreakingDemo.main(ExtentLocalBreakingDemo.java:18)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:578)
      at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:434)
      at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205)
      at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      at ExtentLocalBreakingDemo.lambda$doFill$2(ExtentLocalBreakingDemo.java:53)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:326)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:319)
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      ... 6 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      ... 6 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      ... 6 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      ... 6 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      ... 6 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:52)
      ... 5 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      at ExtentLocalBreakingDemo.lambda$doFill$2(ExtentLocalBreakingDemo.java:53)
      ... 5 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.StructuredTaskScope$ShutdownOnFailure.throwIfFailed(StructuredTaskScope.java:1159)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:57)
      ... 6 more
      Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:74)
      at ExtentLocalBreakingDemo.lambda$doFill$1(ExtentLocalBreakingDemo.java:52)
      ... 5 more
      Caused by: java.lang.NullPointerException: Cannot store to object array because "cache" is null
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.setKeyAndObjectAt(ExtentLocal.java:672)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal$Cache.put(ExtentLocal.java:636)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.slowGet(ExtentLocal.java:446)
      at jdk.incubator.concurrent/jdk.incubator.concurrent.ExtentLocal.get(ExtentLocal.java:437)
      at ExtentLocalBreakingDemo.doFill(ExtentLocalBreakingDemo.java:64)
      ... 6 more

      ---------- BEGIN SOURCE ----------
      import java.util.concurrent.Future;
      import jdk.incubator.concurrent.ExtentLocal;
      import jdk.incubator.concurrent.StructuredTaskScope;

      public class ExtentLocalBreakingDemo {

        private static final int ITERATIONS = 10_000;
        private static final int THRESHOLD = 64;
        private static final int N = 50_000;
        private static final ExtentLocal<int[]> DATA = ExtentLocal.newInstance();

        public static void main(String[] args) throws Exception {

          for (int i = 0; i < ITERATIONS; ++i) {
            System.out.println("Iteration " + i);
            int[] data = new int[N];

            fill(data, 42);

            for (int j = 0; j < N; ++j) {
              if (data[j] != 42) {
                System.out.println("data[" + j + "] != 42");
                System.exit(1);
              }
            }

            System.out.println("OK");
          }
        }

        private static void fill(int[] arr, int value) {
          ExtentLocal
              .where(DATA, arr)
              .run(() -> doFill(value, 0, arr.length));
        }

        private static Void doFill(int value, int begin, int end) {
          if (end <= begin) {
            return null;
          }

          if (end - begin <= THRESHOLD) {
            for (int i = begin; i != end; ++i) {
              DATA.get()[i] = value;
            }
            return null;
          }

          try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
            int middle = begin + (end - begin) / 2;

            Future<Void> left = scope.fork(() -> doFill(value, begin, middle));
            Future<Void> right = scope.fork(() -> doFill(value, middle, end));
            
            // (1) BEGIN
            scope.join();
            scope.throwIfFailed();
            // (1) END

            // (2) BEGIN
            try {
              left.get();
              right.get();
              DATA.get();
            } catch (NullPointerException e) {
              synchronized (ExtentLocalBreakingDemo.class) {
                System.err.println(Thread.currentThread());
                e.printStackTrace();
              }
              throw e;
            }
            // (2) END
          } catch (Exception e) {
            throw new RuntimeException(e);
          }

          return null;
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            aph Andrew Haley
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: