Skip to content
Tcl Source Code History Of Ticket 1593707fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1593707fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1593707fffffffffffffffffffffffffffffffff

  1. Ticket change [2a7476de8a] (rid 118575) by melbardis on 2006-11-09 19:35:00:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      If threads in a multi threaded application (or simply 
      multiple copies of a tclsh) try to open the same file 
      for reading, there appears to be a window of 
      opportunity for windows to return an error, typically 
      a ERROR_SHARING_VIOLATION error.
      
      Additionally (in another of my applications non-tcl) 
      i found that is a thread closes a file and another 
      thread trys to delete the file, the same window can 
      apply.
      
      I have modfied win/tclWinChan.c (8.54a, though same 
      code seems to exist everywhere...) as follows:
      
          /*
           * Now we get to create the file.
           */
          {
              //EPM - windows can screwup when opening same 
      file at same time
              int retry = 5;
              int err;
              while (retry--) {
                  handle = (*tclWinProcs->createFileProc)
      (nativeName, accessMode,
                                                          
      shareMode, NULL, createMode, flags, (HANDLE) NULL);
                  if (handle != INVALID_HANDLE_VALUE) {
                      break;
                  }
                  err = GetLastError();
                  if (err == ERROR_FILE_NOT_FOUND) {
                          // File removed by external 
      circumstances.
                          break;
                  }
                  Sleep(100);
                  //printf("retry... %d\n", retry);
              }
          }
      
      
      if the retry message is uncommented, then the retry 
      was output occasionally when running the test code, 
      with a retry value of 4
      
      note: my machine is a dual-core pentium 2.8 gig
      
      
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "melbardis"
    10. subsystem initialized to: "37. File System"
    11. title initialized to: "win32 error during simultaneous file open for read"
    12. type initialized to: "Bug"
  2. Ticket change [9211d5dbd1] (rid 120722) by melbardis on 2006-11-10 02:35:00:

    1. icomment:
      
      
      File Added - 202137: ct.tcl
      
      
      
    2. login: "melbardis"
    3. mimetype: "text/plain"
    4. username: "melbardis"
  3. Add attachment "ct.tcl" [8b16f23bc7] (rid 127500) by melbardis on 2006-11-10 02:35:00.

  4. Add attachment "tclWinChan.c" [64effa4d58] (rid 92862) by melbardis on 2006-11-10 02:35:53.

  5. Ticket change [bd74cb11de] (rid 101907) by melbardis on 2006-11-10 02:35:53:

    1. icomment:
      
      
      File Added - 202139: tclWinChan.c
      
      
      
    2. login: "melbardis"
    3. mimetype: "text/plain"
    4. username: "melbardis"
  6. Ticket change [ce4a5520f5] (rid 96031) by melbardis on 2007-03-21 20:12:39:

    1. priority changed to: "7 High"
  7. Ticket change [587c218cc0] (rid 117813) by melbardis on 2007-07-19 04:38:20:

    1. icomment:
      Logged In: YES 
      user_id=788816
      Originator: YES
      
      no response when filed under the previous category!
      
      
    2. login: "melbardis"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. subsystem changed to: "49. Threading"
    6. username: "melbardis"
  8. Ticket change [be1ff782f5] (rid 102022) by georgeps on 2007-12-15 05:29:30:

    1. icomment:
      Logged In: YES 
      user_id=585068
      Originator: NO
      
      After reading MSDN I'm not sure this is a bug that is fixable in Tcl, without a hack that really wouldn't be appropriate.
      
      To quote from MSDN: "When a process attempts to open a file that has already been opened in sharing mode, the system compares the requested access and sharing modes to those specified when the file was opened. If you specify an access mode that conflicts with the sharing mode specified in the previous open call, CreateFile fails with a sharing violation (ERROR_SHARING_VIOLATION)."
      
      I think this means you just can't do some things in Windows that you want to do, unless you remove the FILE_SHARE_* flags from the CreateFile call.
      
      However, I just noticed that NativeStat() in the win tree uses "FILE_SHARE_READ | FILE_SHARE_WRITE" (used to detect permissions it seems) with CreateFile.  There could be a race between the stat in one thread, and an open in another.  So even though you only want one handle open, the stat is causing the open to fail in some cases.  This isn't good...
      
      
      
    2. login: "georgeps"
    3. mimetype: "text/plain"
    4. username: "georgeps"