Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_03"
      Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
      Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)

      FULL OS VERSION :
      Windows 7 32-bit

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Running NTFS filesystem (no encryption)

      A DESCRIPTION OF THE PROBLEM :
      I have a small program I wrote to manage filesystem resources. It monitors changes tot he file system using Java 7's new WatchService.

      The particular use case I was testing when it crashed was one were I delete a watched directory one level up from another watched directory.

      In this case the tree looks like

      \\temp\\test\\new\\little

      Test, new, and little are all registered with the watch service. I deleted new (and as a result little as well). When I deleted the directory I got one watch event and then crash.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a directory on the the C Drive (NTFS no encryption) called Temp

      Under that create test
      Under test create both new and old
      Under new create directory little

      Run ResourceManager's main method..

      Now using Windows File Explorer delete the directory \Temp\test\new

      Keep in mind the current test code only gives you 15 seconds to do that from when it was started..

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expect it to report the delete so that I might delete the Directory object I use to represent that directory and any other results would be basically ignored.

      What I get instead is a dump file. This rarely occurs and I have only been able to reproduce it once since.
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77da2a86, pid=7376, tid=6436
      #
      # JRE version: 7.0_03-b05
      # Java VM: Java HotSpot(TM) Client VM (22.1-b02 mixed mode, sharing windows-x86 )
      # Problematic frame:
      # C [ntdll.dll+0x52a86]
      #
      # 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.sun.com/bugreport/crash.jsp
      #

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

      Current thread (0x0061a400): WatcherThread [stack: 0x008c0000,0x00910000] [id=6436]

      siginfo: ExceptionCode=0xc0000005, reading address 0x00007fec

      Registers:
      EAX=0x03abdf98, EBX=0x03ab5f90, ECX=0x00007fec, EDX=0x00007fec
      ESP=0x0090f68c, EBP=0x0090f6b4, ESI=0x03abdf90, EDI=0x00710000
      EIP=0x77da2a86, EFLAGS=0x00010246

        Top of Stack: (sp=0x0090f68c)
      0x0090f68c: 00710000 03ab5f90 00000000 10001000
      0x0090f69c: 0090f79c 77d6d46d 03ab5f98 00007fec
      0x0090f6ac: 77e14300 00710000 0090f7ac 77da2d05
      0x0090f6bc: 00710000 03abdf90 0090f77c 00000000
      0x0090f6cc: 5c8cbafc 00000000 00710000 03ab5f98
      0x0090f6dc: 6ce87f37 007a001a 00000004 00000001
      0x0090f6ec: 00000044 0061bbb0 007100c4 00712fe8
      0x0090f6fc: 00000004 00710000 00712fe8 00530358

      Instructions: (pc=0x77da2a86)
      0x77da2a66: 85 be 49 03 00 80 7d 14 00 0f 85 c2 49 03 00 8b
      0x77da2a76: 56 0c 8d 46 08 8b 08 89 4d f0 8b 49 04 89 55 f4
      0x77da2a86: 8b 12 3b d1 0f 85 25 34 fd ff 3b d0 0f 85 1d 34
      0x77da2a96: fd ff 0f b7 06 29 47 78 8b 87 b8 00 00 00 85 c0


      Register to memory mapping:

      EAX=0x03abdf98 is an unknown value
      EBX=0x03ab5f90 is an unknown value
      ECX=0x00007fec is an unknown value
      EDX=0x00007fec is an unknown value
      ESP=0x0090f68c is an unknown value
      EBP=0x0090f6b4 is an unknown value
      ESI=0x03abdf90 is an unknown value
      EDI=0x00710000 is an unknown value


      Stack: [0x008c0000,0x00910000], sp=0x0090f68c, free space=317k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      C [ntdll.dll+0x52a86] RtlTryEnterCriticalSection+0xee
      C [ntdll.dll+0x52d05] RtlTryEnterCriticalSection+0x36d
      C [ntdll.dll+0x52bf0] RtlTryEnterCriticalSection+0x258
      C [kernel32.dll+0x4f14c] HeapFree+0x14
      C [msvcr100.dll+0x1016a] free+0x1c
      V [jvm.dll+0x5c298]
      V [jvm.dll+0x5c387]
      V [jvm.dll+0x13e5a7]
      V [jvm.dll+0x1720b9]
      C [msvcr100.dll+0x5c6de] endthreadex+0x3a
      C [msvcr100.dll+0x5c788] endthreadex+0xe4
      C [kernel32.dll+0x51114] BaseThreadInitThunk+0x12
      C [ntdll.dll+0x5b299] RtlInitializeExceptionChain+0x63
      C [ntdll.dll+0x5b26c] RtlInitializeExceptionChain+0x36


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

      Java Threads: ( => current thread )
        0x03afa000 JavaThread "Thread-1" daemon [_thread_in_native, id=6684, stack(0x039a0000,0x039f0000)]
        0x0071a400 JavaThread "DestroyJavaVM" [_thread_blocked, id=8128, stack(0x007b0000,0x00800000)]
        0x03af6000 JavaThread "Thread-0" [_thread_blocked, id=6232, stack(0x039f0000,0x03a40000)]
        0x03ab0c00 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=7224, stack(0x00b60000,0x00bb0000)]
        0x005fcc00 JavaThread "Service Thread" daemon [_thread_blocked, id=6632, stack(0x03a40000,0x03a90000)]
        0x005f8000 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=4364, stack(0x00b10000,0x00b60000)]
        0x005f6000 JavaThread "Attach Listener" daemon [_thread_blocked, id=3848, stack(0x03900000,0x03950000)]
        0x005f3000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3860, stack(0x03870000,0x038c0000)]
        0x005e3400 JavaThread "Finalizer" daemon [_thread_blocked, id=7284, stack(0x00a90000,0x00ae0000)]
        0x005de800 JavaThread "Reference Handler" daemon [_thread_blocked, id=3964, stack(0x00960000,0x009b0000)]

      Other Threads:
        0x005dcc00 VMThread [stack: 0x009e0000,0x00a30000] [id=4956]
      =>0x0061a400 WatcherThread [stack: 0x008c0000,0x00910000] [id=6436]

      VM state:not at safepoint (normal execution)

      VM Mutex/Monitor currently owned by a thread: None

      Heap
       def new generation total 4928K, used 837K [0x234a0000, 0x239f0000, 0x289f0000)
        eden space 4416K, 18% used [0x234a0000, 0x23571590, 0x238f0000)
        from space 512K, 0% used [0x238f0000, 0x238f0000, 0x23970000)
        to space 512K, 0% used [0x23970000, 0x23970000, 0x239f0000)
       tenured generation total 10944K, used 0K [0x289f0000, 0x294a0000, 0x334a0000)
         the space 10944K, 0% used [0x289f0000, 0x289f0000, 0x289f0200, 0x294a0000)
       compacting perm gen total 12288K, used 538K [0x334a0000, 0x340a0000, 0x374a0000)
         the space 12288K, 4% used [0x334a0000, 0x33526b20, 0x33526c00, 0x340a0000)
          ro space 10240K, 45% used [0x374a0000, 0x37922e40, 0x37923000, 0x37ea0000)
          rw space 12288K, 54% used [0x37ea0000, 0x385267b8, 0x38526800, 0x38aa0000)

      Code Cache [0x01830000, 0x018d0000, 0x03830000)
       total_blobs=171 nmethods=22 adapters=86 free_code_cache=32147Kb largest_free_block=32918976

      Dynamic libraries:
      0x00c00000 - 0x00c2e000 C:\Java\jdk1.7.0\bin\java.exe
      0x77d50000 - 0x77e8c000 C:\Windows\SYSTEM32\ntdll.dll
      0x77b50000 - 0x77c24000 C:\Windows\system32\kernel32.dll
      0x75f60000 - 0x75faa000 C:\Windows\system32\KERNELBASE.dll
      0x77620000 - 0x776c0000 C:\Windows\system32\ADVAPI32.dll
      0x768d0000 - 0x7697c000 C:\Windows\system32\msvcrt.dll
      0x77ef0000 - 0x77f09000 C:\Windows\SYSTEM32\sechost.dll
      0x77970000 - 0x77a11000 C:\Windows\system32\RPCRT4.dll
      0x76610000 - 0x766d9000 C:\Windows\system32\USER32.dll
      0x775d0000 - 0x7761e000 C:\Windows\system32\GDI32.dll
      0x77f60000 - 0x77f6a000 C:\Windows\system32\LPK.dll
      0x77a20000 - 0x77abd000 C:\Windows\system32\USP10.dll
      0x74db0000 - 0x74f4e000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd\COMCTL32.dll
      0x76320000 - 0x76377000 C:\Windows\system32\SHLWAPI.dll
      0x77ec0000 - 0x77edf000 C:\Windows\system32\IMM32.DLL
      0x776c0000 - 0x7778c000 C:\Windows\system32\MSCTF.dll
      0x50160000 - 0x5021e000 C:\Java\jdk1.7.0\jre\bin\msvcr100.dll
      0x6cd40000 - 0x6d068000 C:\Java\jdk1.7.0\jre\bin\client\jvm.dll
      0x72330000 - 0x72337000 C:\Windows\system32\WSOCK32.dll
      0x77790000 - 0x777c5000 C:\Windows\system32\WS2_32.dll
      0x77eb0000 - 0x77eb6000 C:\Windows\system32\NSI.dll
      0x74620000 - 0x74652000 C:\Windows\system32\WINMM.dll
      0x77f70000 - 0x77f75000 C:\Windows\system32\PSAPI.DLL
      0x6a3e0000 - 0x6a3ec000 C:\Java\jdk1.7.0\jre\bin\verify.dll
      0x59f00000 - 0x59f20000 C:\Java\jdk1.7.0\jre\bin\java.dll
      0x59eb0000 - 0x59ec3000 C:\Java\jdk1.7.0\jre\bin\zip.dll
      0x10000000 - 0x10007000 C:\Program Files\Devel\IntelliJ\11.0.2\bin\breakgen.dll
      0x59710000 - 0x59724000 C:\Java\jdk1.7.0\jre\bin\net.dll
      0x759b0000 - 0x759ec000 C:\Windows\system32\mswsock.dll
      0x759a0000 - 0x759a6000 C:\Windows\System32\wship6.dll
      0x60ad0000 - 0x60adf000 C:\Java\jdk1.7.0\jre\bin\nio.dll
      0x744f0000 - 0x74511000 C:\Windows\system32\ntmarta.dll
      0x77f10000 - 0x77f55000 C:\Windows\system32\WLDAP32.dll
      0x74d70000 - 0x74d82000 C:\Windows\system32\SAMLIB.dll

      VM Arguments:
      jvm_args: -Didea.launcher.port=7533 -Didea.launcher.bin.path=C:\Program Files\Devel\IntelliJ\11.0.2\bin -Dfile.encoding=UTF-8
      java_command: com.intellij.rt.execution.application.AppMain org.xpertss.darwin.server.res.ResourceManager
      Launcher Type: SUN_STANDARD

      Environment Variables:
      JAVA_HOME=C:\Java\jdk1.5.0
      PATH=C:\Program Files\Devel\IntelliJ\11.0.2\bin\..\.\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Java\jdk1.5.0\bin;C:\Software\maven\bin;C:\Software\Ruby\bin;C:\Program Files\Devel\Subversion;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;c:\Program Files\WIDCOMM\Bluetooth Software\;C:\Software\tools\unix;C:\Software\tools\pstools;C:\Software\tools\sim;C:\Program Files\Common Files\Teleca Shared;C:\Program Files\Windows Live\Shared;c:\program files\devel\intellij\11.0.2\jre\jre\bin
      USERNAME=cfloersch
      OS=Windows_NT
      PROCESSOR_IDENTIFIER=x86 Family 6 Model 37 Stepping 5, GenuineIntel



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

      OS: Windows 7 Build 7600

      CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

      Memory: 4k page, physical 3594068k(847000k free), swap 7186372k(3298452k free)

      vm_info: Java HotSpot(TM) Client VM (22.1-b02) for windows-x86 JRE (1.7.0_03-b05), built on Feb 3 2012 20:43:37 by "java_re" with unknown MS VC++:1600

      time: Fri Feb 24 16:24:27 2012
      elapsed time: 5 seconds


      REPRODUCIBILITY :
      This bug can be reproduced rarely.

      ---------- BEGIN SOURCE ----------
      package res;


      import java.io.IOException;
      import java.nio.ByteBuffer;
      import java.nio.file.FileSystems;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.nio.file.StandardWatchEventKinds;
      import java.nio.file.WatchEvent;
      import java.nio.file.WatchKey;
      import java.nio.file.WatchService;
      import java.util.Objects;
      import java.util.concurrent.TimeUnit;

      import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
      import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
      import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
      import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
      import static java.nio.file.StandardWatchEventKinds.OVERFLOW;



      /**
       * ResourceManager monitors the resource directory for changes and for access control files.
       * It attempts to keep track of all the directories and what access controls exist on each
       * one.
       * <p>
       * When requests for a resource are made it translates the path into a file path. It validates
       * any authorization constraints that exist throwing an Authorization Exception if they are not
       * met. Otherwise, it loads the file's contents and caches it internally returning a read-only
       * copy to the caller.
       * <p>
       * If a resource changes on the disk this will clear the cached copy. If an access control
       * file changes it will reload and rebuild the authorization constraints.
       */
      public class ResourceManager implements Runnable {


         private Path baseResourceDir;
         private boolean running;
         private Directory root;
         private Thread thread;
         
         public ResourceManager(Path baseResourceDir)
         {
            this.baseResourceDir = Objects.requireNonNull(baseResourceDir, "Base resource directory may not be null");
         }


         public void start() throws Exception
         {
            if(thread == null) {
               thread = new Thread(this);
               thread.start();
               running = true;
            }
         }
         
         public void stop() throws Exception
         {
            if(thread != null) {
               running = false;
               thread.join(5000);
            }
         }
         
         

         /**
          * Throws some sort of ResourceDoesNotExistException or AuthorizationException if the
          * resource does not exist or the caller does not have sufficient authorization to
          * access it.
          *
          * @param path
          * @return
          */
         public ByteBuffer retrieve(String path)
         {
            return null;
         }










         /**
          * Process all events for keys queued to the watcher
          * <p>
          * If you rename the base directory being monitored the system does not catch
          * that. All subsequent directory events are then reported improperly because
          * watchable still thinks it has the original name. Resolving child names
          * resolves using incorrect parent directory.
          */
         public void run()
         {
            long start = System.currentTimeMillis();
            
            try(WatchService watcher = FileSystems.getDefault().newWatchService()) {
               root = Directory.createRoot(watcher, baseResourceDir);

               while (System.currentTimeMillis() - start < 15000) {
         
                  // wait for key to be signalled
                  WatchKey key = watcher.poll(10, TimeUnit.SECONDS);
                  if(key != null) {

                     Path watched = (Path) key.watchable();
                     Directory dir = root.resolve(watched);

                     if(dir != null) {
                        for (WatchEvent<?> event: key.pollEvents()) {
                           WatchEvent.Kind kind = event.kind();

                           // TBD - provide example of how OVERFLOW event is handled
                           if (kind == OVERFLOW) {
                              System.out.println("Overflow encountered");
                              continue;
                           }

                           // Context for directory entry event is the file name of entry
                           WatchEvent<Path> ev = cast(event);
                           Path name = ev.context();
                           Path child = watched.resolve(name);

                           // print out event
                           System.out.format("%s - %s: %s\n", watched, event.kind().name(), name);


                           if(kind == ENTRY_DELETE) {
                              dir.delete(watcher, name);
                           } else if(kind == ENTRY_CREATE) {
                              dir.create(watcher, name);
                           } else if(kind == ENTRY_MODIFY) {
                              dir.modify(watcher, name);
                           }

                        }
                     }

                     // reset key and remove from set if directory no longer accessible
                     if (!key.reset() && watched.equals(baseResourceDir)) {
                        root = null;
                        break;
                     }
                  }
               }
            } catch(Exception e) {
               System.err.format("Error %s", e); // TODO What should we do here??
            }
            thread = null;
            System.out.println(root);
         }








         @SuppressWarnings("unchecked")
         static <T> WatchEvent<T> cast(WatchEvent<?> event) {
            return (WatchEvent<T>)event;
         }

         
         
         public static void main(String[] args) throws Exception
         {
            ResourceManager mgr = new ResourceManager(Paths.get("/Temp/test"));
            mgr.start();
         }
         
      }










      package res;

      import java.io.IOException;
      import java.nio.file.FileSystems;
      import java.nio.file.FileVisitResult;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.nio.file.SimpleFileVisitor;
      import java.nio.file.WatchKey;
      import java.nio.file.WatchService;
      import java.nio.file.attribute.Ba


      ( This report has more than 16,000 characters and has been truncated. )

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: