[GHC] #12725: T7037 is broken on Windows

GHC ghc-devs at haskell.org
Tue Oct 18 17:10:50 UTC 2016


#12725: T7037 is broken on Windows
---------------------------------+--------------------------------------
        Reporter:  bgamari       |                Owner:
            Type:  bug           |               Status:  new
        Priority:  normal        |            Milestone:  8.2.1
       Component:  Compiler      |              Version:  8.1
      Resolution:                |             Keywords:
Operating System:  Windows       |         Architecture:  x86_64 (amd64)
 Type of failure:  None/Unknown  |            Test Case:
      Blocked By:                |             Blocking:
 Related Tickets:                |  Differential Rev(s):
       Wiki Page:                |
---------------------------------+--------------------------------------

Comment (by Phyx-):

 This is a good testcase and it illustrates the problem nicely.

 I don't think it's GCC, I think ultimately, it's some emulation layer
 somewhere.

 `execv` is emulated somewhere, not by calling Windows's `CreateProcess`
 but probably some other posix function. I suspect it's somewhere in
 https://github.com/mirror/newlib-cygwin but that wouldn't explain the
 mingw version of GCC.

 If you replace `execv` with `CreateProcess` the example works correctly in
 all compilers

 {{{
 #include <unistd.h>
 #include <windows.h>

 int main(int argc, char *argv[]) {
     TCHAR * args[2] = {"ok", NULL};

     STARTUPINFO si;
     PROCESS_INFORMATION pi;

     ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
     ZeroMemory(&pi, sizeof(pi));

     // Start the child process.
     if (!CreateProcess("ok.exe",   // No module name (use command line)
         args[0],        // Command line
         NULL,           // Process handle not inheritable
         NULL,           // Thread handle not inheritable
         FALSE,          // Set handle inheritance to FALSE
         0,              // No creation flags
         NULL,           // Use parent's environment block
         NULL,           // Use parent's starting directory
         &si,            // Pointer to STARTUPINFO structure
         &pi)           // Pointer to PROCESS_INFORMATION structure
         )
     {
         return 1;
     }

     // Wait until child process exits.
     WaitForSingleObject(pi.hProcess, INFINITE);

     // Close process and thread handles.
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);

     return 0;
 }
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12725#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list