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

(fs) Crash while using WatchService

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u51
    • Fix Version/s: tbd_major
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_8

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      FULL OS VERSION :
      Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      I have a thread that monitors a directory for new files. For each file, the watch key is being canceled and a new one is registered. When creating many new files in the monitored directory the JRE crashes with EXCEPTION_ACCESS_VIOLATION.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffe62431b05, pid=1100, tid=3864
      #
      # JRE version: Java(TM) SE Runtime Environment (8.0_51-b16) (build 1.8.0_51-b16)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.51-b03 mixed mode windows-amd64 compressed oops)
      # Problematic frame:
      # C [ntdll.dll+0x31b05]
      #
      # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
      #
      # If you would like to submit a bug report, please visit:
      # http://bugreport.java.com/bugreport/crash.jsp
      #

      --------------- T H R E A D ---------------

      Current thread (0x000000001e1ab000): JavaThread "Thread-1" daemon [_thread_in_vm, id=3864, stack(0x000000001ebd0000,0x000000001ecd0000)]

      siginfo: ExceptionCode=0xc0000005, reading address 0xffffffffffffffff

      Registers:
      RAX=0x0000000000000403, RBX=0x0000000002050000, RCX=0x0000000000000000, RDX=0x0000000000000000
      RSP=0x000000001ecce960, RBP=0x0000000000000000, RSI=0x0000000002054540, RDI=0x000000001e1b5b90
      R8 =0x000000001e1b5ba0, R9 =0x0000000000004030, R10=0x00007ffe62405730, R11=0x0000000053407bb0
      R12=0x0069006600000014, R13=0x0000000300000000, R14=0x000000001e1b5ba0, R15=0x0000000000000403
      RIP=0x00007ffe62431b05, EFLAGS=0x0000000000010246

      Top of Stack: (sp=0x000000001ecce960)
      0x000000001ecce960: 0000000000000000 0000000000000000
      0x000000001ecce970: 0000000000000000 0000000000000000
      0x000000001ecce980: 0000000000000000 0000000000000000
      0x000000001ecce990: 0000000000000001 0000000000000000
      0x000000001ecce9a0: 0000000000000000 0000000000000001
      0x000000001ecce9b0: 0000000000000000 0000000000000001
      0x000000001ecce9c0: 0000000000000000 0000000000010000
      0x000000001ecce9d0: 0000000000000000 0000000000000000
      0x000000001ecce9e0: 000000001e1b5b90 0000000000000000
      0x000000001ecce9f0: 0000000000000001 0000000000000000
      0x000000001eccea00: 0000000000000000 0000000000000000
      0x000000001eccea10: 00000000000003ff 0000000000000000
      0x000000001eccea20: 0000000000000000 0000000000000000
      0x000000001eccea30: 0000000000000000 0000000000000000
      0x000000001eccea40: 0000000007000403 0000000000000000
      0x000000001eccea50: 0000000002000002 0000000000000000

      Instructions: (pc=0x00007ffe62431b05)
      0x00007ffe62431ae5: 47 0b 0f 85 ae 18 00 00 0f b7 47 08 49 3b c7 0f
      0x00007ffe62431af5: 82 19 19 00 00 4c 8d 47 10 4d 8b 28 4c 8b 67 18
      0x00007ffe62431b05: 49 8b 0c 24 4d 8b 4d 08 49 3b c9 0f 85 dd 18 00
      0x00007ffe62431b15: 00 49 3b c8 0f 85 d4 18 00 00 48 29 83 c0 00 00


      Register to memory mapping:

      RAX=0x0000000000000403 is an unknown value
      RBX=0x0000000002050000 is an unknown value
      RCX=0x0000000000000000 is an unknown value
      RDX=0x0000000000000000 is an unknown value
      RSP=0x000000001ecce960 is pointing into the stack for thread: 0x000000001e1ab000
      RBP=0x0000000000000000 is an unknown value
      RSI=0x0000000002054540 is an unknown value
      RDI=0x000000001e1b5b90 is an unknown value
      R8 =0x000000001e1b5ba0 is an unknown value
      R9 =0x0000000000004030 is an unknown value
      R10=0x00007ffe62405730 is an unknown value
      R11=0x0000000053407bb0 is an unknown value
      R12=0x0069006600000014 is an unknown value
      R13=0x0000000300000000 is an unknown value
      R14=0x000000001e1b5ba0 is an unknown value
      R15=0x0000000000000403 is an unknown value


      Stack: [0x000000001ebd0000,0x000000001ecd0000], sp=0x000000001ecce960, free space=1018k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)

      Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
      j sun.misc.Unsafe.allocateMemory(J)J+0
      j sun.nio.fs.NativeBuffer.<init>(I)V+10
      j sun.nio.fs.NativeBuffers.allocNativeBuffer(I)Lsun/nio/fs/NativeBuffer;+16
      j sun.nio.fs.NativeBuffers.getNativeBuffer(I)Lsun/nio/fs/NativeBuffer;+17
      j sun.nio.fs.WindowsWatchService$Poller.implRegister(Ljava/nio/file/Path;Ljava/util/Set;[Ljava/nio/file/WatchEvent$Modifier;)Ljava/lang/Object;+350
      j sun.nio.fs.AbstractPoller.processRequests()Z+116
      j sun.nio.fs.WindowsWatchService$Poller.run()V+27
      j java.lang.Thread.run()V+11
      v ~StubRoutines::call_stub

      --------------- P R O C E S S ---------------

      Java Threads: ( => current thread )
      =>0x000000001e1ab000 JavaThread "Thread-1" daemon [_thread_in_vm, id=3864, stack(0x000000001ebd0000,0x000000001ecd0000)]
        0x000000001e196000 JavaThread "Thread-0" [_thread_blocked, id=10164, stack(0x000000001ead0000,0x000000001ebd0000)]
        0x000000001e190000 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=8896, stack(0x000000001e9d0000,0x000000001ead0000)]
        0x000000001e060800 JavaThread "Service Thread" daemon [_thread_blocked, id=5044, stack(0x000000001e710000,0x000000001e810000)]
        0x000000001e049000 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=8744, stack(0x000000001e610000,0x000000001e710000)]
        0x000000001e040800 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=8760, stack(0x000000001e510000,0x000000001e610000)]
        0x000000001e03f000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=5984, stack(0x000000001e410000,0x000000001e510000)]
        0x000000001e038000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=5740, stack(0x000000000eec0000,0x000000000efc0000)]
        0x000000001e034800 JavaThread "Attach Listener" daemon [_thread_blocked, id=4816, stack(0x000000000edc0000,0x000000000eec0000)]
        0x000000001e033800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=9560, stack(0x000000000ecc0000,0x000000000edc0000)]
        0x0000000002259800 JavaThread "Finalizer" daemon [_thread_blocked, id=7308, stack(0x000000000ebc0000,0x000000000ecc0000)]
        0x000000000cccd800 JavaThread "Reference Handler" daemon [_thread_blocked, id=9848, stack(0x000000000eac0000,0x000000000ebc0000)]
        0x000000000205e000 JavaThread "main" [_thread_in_native, id=10220, stack(0x0000000002060000,0x0000000002160000)]

      Other Threads:
        0x000000000ccc9000 VMThread [stack: 0x000000000e9c0000,0x000000000eac0000] [id=6528]
        0x000000001e061000 WatcherThread [stack: 0x000000001e810000,0x000000001e910000] [id=2964]

      VM state:not at safepoint (normal execution)

      VM Mutex/Monitor currently owned by a thread: None

      Heap:
       PSYoungGen total 76288K, used 7864K [0x000000076b400000, 0x0000000770900000, 0x00000007c0000000)
        eden space 65536K, 12% used [0x000000076b400000,0x000000076bbae268,0x000000076f400000)
        from space 10752K, 0% used [0x000000076fe80000,0x000000076fe80000,0x0000000770900000)
        to space 10752K, 0% used [0x000000076f400000,0x000000076f400000,0x000000076fe80000)
       ParOldGen total 175104K, used 0K [0x00000006c1c00000, 0x00000006cc700000, 0x000000076b400000)
        object space 175104K, 0% used [0x00000006c1c00000,0x00000006c1c00000,0x00000006cc700000)
       Metaspace used 3943K, capacity 4572K, committed 4864K, reserved 1056768K
        class space used 449K, capacity 460K, committed 512K, reserved 1048576K

      Card table byte_map: [0x0000000002620000,0x0000000002e20000] byte_map_base: 0xffffffffff012000

      Marking Bits: (ParMarkBitMap*) 0x00000000539e4040
       Begin Bits: [0x0000000003b70000, 0x0000000007b00000)
       End Bits: [0x0000000007b00000, 0x000000000ba90000)

      Polling page: 0x0000000000760000

      CodeCache: size=245760Kb used=1275Kb max_used=1275Kb free=244484Kb
       bounds [0x000000000f010000, 0x000000000f280000, 0x000000001e010000]
       total_blobs=401 nmethods=110 adapters=204
       compilation: enabled

      Compilation events (10 events):
      Event: 0.106 Thread 0x000000001e049000 105 3 java.util.HashMap::putVal (300 bytes)
      Event: 0.107 Thread 0x000000001e049000 nmethod 105 0x000000000f149dd0 code [0x000000000f14a040, 0x000000000f14b338]
      Event: 0.107 Thread 0x000000001e049000 104 3 java.util.HashMap::put (13 bytes)
      Event: 0.107 Thread 0x000000001e049000 nmethod 104 0x000000000f14ba10 code [0x000000000f14bba0, 0x000000000f14bf58]
      Event: 0.109 Thread 0x000000001e049000 106 3 java.util.HashMap::getNode (148 bytes)
      Event: 0.110 Thread 0x000000001e049000 nmethod 106 0x000000000f14d6d0 code [0x000000000f14d8a0, 0x000000000f14e248]
      Event: 0.110 Thread 0x000000001e049000 107 1 java.lang.reflect.Field::getName (5 bytes)
      Event: 0.110 Thread 0x000000001e049000 nmethod 107 0x000000000f14e510 code [0x000000000f14e660, 0x000000000f14e770]
      Event: 0.110 Thread 0x000000001e049000 108 1 java.lang.Enum::ordinal (5 bytes)
      Event: 0.110 Thread 0x000000001e049000 nmethod 108 0x000000000f14e7d0 code [0x000000000f14e920, 0x000000000f14ea30]

      GC Heap History (0 events):
      No events

      Deoptimization events (0 events):
      No events

      Internal exceptions (10 events):
      Event: 0.104 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b510278) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.104 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b510aa8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b5112d8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b511b08) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b512338) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b512b68) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b513398) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b513bc8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b5143f8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]
      Event: 0.105 Thread 0x000000000205e000 Exception <a 'sun/nio/fs/WindowsException'> (0x000000076b514c28) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u51\3951\hotspot\src\share\vm\prims\jni.cpp, line 709]

      Events (10 events):
      Event: 0.109 loading class sun/nio/ch/Util$1
      Event: 0.109 loading class sun/nio/ch/Util$1 done
      Event: 0.109 loading class sun/nio/ch/Util$BufferCache
      Event: 0.109 loading class sun/nio/ch/Util$BufferCache done
      Event: 0.109 loading class java/nio/DirectByteBuffer$Deallocator
      Event: 0.109 loading class java/nio/DirectByteBuffer$Deallocator done
      Event: 0.109 loading class sun/nio/ch/IOStatus
      Event: 0.109 loading class sun/nio/ch/IOStatus done
      Event: 0.110 loading class java/util/concurrent/LinkedBlockingDeque$Node
      Event: 0.110 loading class java/util/concurrent/LinkedBlockingDeque$Node done


      Dynamic libraries:
      0x00007ff625170000 - 0x00007ff6251a7000 C:\Program Files\Java\jdk1.8.0_51\bin\java.exe
      0x00007ffe62400000 - 0x00007ffe625ac000 C:\WINDOWS\SYSTEM32\ntdll.dll
      0x00007ffe5fc60000 - 0x00007ffe5fd9e000 C:\WINDOWS\system32\KERNEL32.DLL
      0x00007ffe5f680000 - 0x00007ffe5f795000 C:\WINDOWS\system32\KERNELBASE.dll
      0x00007ffe5d840000 - 0x00007ffe5d8ce000 C:\WINDOWS\system32\apphelp.dll
      0x00007ffe55b70000 - 0x00007ffe55bc3000 C:\WINDOWS\AppPatch\AppPatch64\AcGenral.DLL
      0x00007ffe617e0000 - 0x00007ffe6188a000 C:\WINDOWS\system32\msvcrt.dll
      0x00007ffe5f360000 - 0x00007ffe5f38e000 C:\WINDOWS\SYSTEM32\SspiCli.dll
      0x00007ffe60110000 - 0x00007ffe60164000 C:\WINDOWS\system32\SHLWAPI.dll
      0x00007ffe620a0000 - 0x00007ffe62217000 C:\WINDOWS\system32\USER32.dll
      0x00007ffe61890000 - 0x00007ffe61a24000 C:\WINDOWS\system32\ole32.dll
      0x00007ffe60200000 - 0x00007ffe61719000 C:\WINDOWS\system32\SHELL32.dll
      0x00007ffe5ec40000 - 0x00007ffe5ec61000 C:\WINDOWS\SYSTEM32\USERENV.dll
      0x00007ffe61a30000 - 0x00007ffe61ada000 C:\WINDOWS\system32\ADVAPI32.dll
      0x00007ffe50ff0000 - 0x00007ffe5100e000 C:\WINDOWS\SYSTEM32\MPR.dll
      0x00007ffe5fe70000 - 0x00007ffe5ffb1000 C:\WINDOWS\system32\RPCRT4.dll
      0x00007ffe5fc00000 - 0x00007ffe5fc59000 C:\WINDOWS\SYSTEM32\sechost.dll
      0x00007ffe61cf0000 - 0x00007ffe61f01000 C:\WINDOWS\SYSTEM32\combase.dll
      0x00007ffe5ffc0000 - 0x00007ffe60110000 C:\WINDOWS\system32\GDI32.dll
      0x00007ffe5f560000 - 0x00007ffe5f575000 C:\WINDOWS\SYSTEM32\profapi.dll
      0x00007ffe5e780000 - 0x00007ffe5e832000 C:\WINDOWS\SYSTEM32\SHCORE.dll
      0x00007ffe61fd0000 - 0x00007ffe62006000 C:\WINDOWS\system32\IMM32.DLL
      0x00007ffe5fa90000 - 0x00007ffe5fbe2000 C:\WINDOWS\system32\MSCTF.dll
      0x00007ffe5f520000 - 0x00007ffe5f54f000 C:\WINDOWS\system32\nvinitx.dll
      0x000000000f000000 - 0x000000000f006000 C:\Program Files\NVIDIA Corporation\CoProcManager\detoured.dll
      0x00007ffe5d160000 - 0x00007ffe5d1bf000 C:\Program Files\NVIDIA Corporation\CoProcManager\nvd3d9wrapx.dll
      0x00007ffe62220000 - 0x00007ffe623fa000 C:\WINDOWS\system32\SETUPAPI.dll
      0x00007ffe5f630000 - 0x00007ffe5f67f000 C:\WINDOWS\system32\CFGMGR32.dll
      0x00007ffe5cfc0000 - 0x00007ffe5d006000 C:\Program Files\NVIDIA Corporation\CoProcManager\nvdxgiwrapx.dll
      0x00007ffe5d8d0000 - 0x00007ffe5db4a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.17810_none_6240b9c7ecbd0bda\COMCTL32.dll
      0x0000000052dc0000 - 0x0000000052e92000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\msvcr100.dll
      0x00000000531e0000 - 0x0000000053a63000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\server\jvm.dll
      0x00007ffe5ae20000 - 0x00007ffe5ae29000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
      0x00007ffe5d020000 - 0x00007ffe5d042000 C:\WINDOWS\SYSTEM32\WINMM.dll
      0x00007ffe5d050000 - 0x00007ffe5d05a000 C:\WINDOWS\SYSTEM32\VERSION.dll
      0x00007ffe5fbf0000 - 0x00007ffe5fbf7000 C:\WINDOWS\system32\PSAPI.DLL
      0x00007ffe61ae0000 - 0x00007ffe61b3a000 C:\WINDOWS\system32\WS2_32.dll
      0x00007ffe5cda0000 - 0x00007ffe5cdca000 C:\WINDOWS\SYSTEM32\WINMMBASE.dll
      0x00007ffe60170000 - 0x00007ffe60179000 C:\WINDOWS\system32\NSI.dll
      0x00007ffe5e230000 - 0x00007ffe5e258000 C:\WINDOWS\SYSTEM32\DEVOBJ.dll
      0x0000000054500000 - 0x000000005450f000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\verify.dll
      0x0000000054470000 - 0x0000000054499000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\java.dll
      0x0000000054450000 - 0x0000000054466000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\zip.dll
      0x00007ffe5ad60000 - 0x00007ffe5ad70000 C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1\bin\breakgen64.dll
      0x00000000531c0000 - 0x00000000531da000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\net.dll
      0x00007ffe5ed90000 - 0x00007ffe5ede9000 C:\WINDOWS\system32\mswsock.dll
      0x00000000531a0000 - 0x00000000531b1000 C:\Program Files\Java\jdk1.8.0_51\jre\bin\nio.dll
      0x00007ffe5bb90000 - 0x00007ffe5bd19000 C:\WINDOWS\SYSTEM32\dbghelp.dll

      VM Arguments:
      jvm_args: -Didea.launcher.port=7539 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1\bin -Dfile.encoding=windows-1252
      java_command: com.intellij.rt.execution.application.AppMain com.company.Main
      java_class_path (initial): C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\avihai\Google Drive\Tests\TestCrash\out\production\TestCrash;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1\lib\idea_rt.jar
      Launcher Type: SUN_STANDARD

      Environment Variables:
      JAVA_HOME=C:\Program Files\Java\jdk1.8.0_51
      PATH=C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Tools;C:\MVN\bin;C:\opscode\chefdk\bin;C:\opscode\chefdk\embedded\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files\nodejs\;C:\Users\avihai\AppData\Roaming\npm;C:\Users\avihai\AppData\Local\Programs\EmEditor
      USERNAME=avihai
      OS=Windows_NT
      PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel



      --------------- S Y S T E M ---------------

      OS:

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      package com.company;

      import java.io.IOException;
      import java.nio.file.*;

      public class Main {
          private static final String MONITORED_DIRECTORY_PATH = "c:\\temp\\test";

          private static class WatcherThread implements Runnable {
              private final Path monitoredDirectoryPath;
              private WatchKey activeWatch = null;

              private WatcherThread(Path monitoredDirectoryPath) {
                  this.monitoredDirectoryPath = monitoredDirectoryPath;
              }

              @Override
              public void run() {
                  try {
                      try (WatchService watcher = FileSystems.getDefault().newWatchService()) {
                          monitorDirectory(watcher);
                          monitorLoop(watcher);
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }

              private void monitorDirectory(WatchService watcher) throws IOException {
                  // Cancel current watch
                  if (activeWatch != null) {
                      activeWatch.cancel();
                      activeWatch = null;
                  }

                  // Add a watch on the directory
                  activeWatch = monitoredDirectoryPath.register(watcher, StandardWatchEventKinds.ENTRY_CREATE);
              }


              private void monitorLoop(WatchService watcher) throws InterruptedException, IOException {
                  while (true) {
                      watcher.take();
                      monitorDirectory(watcher);
                  }
              }
          }

          public static void main(String[] args) {
              try {
                  // Clean the monitored dir
                  Path dir = Paths.get(MONITORED_DIRECTORY_PATH);
                  Files.createDirectories(dir);
                  for (int i = 0; i < 100; i++) {
                      Path path = Paths.get(MONITORED_DIRECTORY_PATH, String.format("file_%d.txt", i));
                      Files.deleteIfExists(path);
                  }

                  Thread thread = new Thread(new WatcherThread(dir));
                  thread.start();

                  // Write many files to the monitored dir, to wake the watcher multiple times
                  for (int i = 0; i < 100; i++) {
                      Path path = Paths.get(MONITORED_DIRECTORY_PATH, String.format("file_%d.txt", i));
                      Files.write(path, "text".getBytes());
                  }

                  Thread.sleep(1000);
                  thread.interrupt();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: