This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

1.5.16: DuplicateHandle(Out) failed (e=6)


I recently upgraded from Cygwin 1.5.6-1 to 1.5.16-1.  
I received the following error from GNU make 3.80 when I ran âmkâ in Cygwin 1.5.16: 

process_easy: DuplicateHandle(Out) failed (e=6)
t:/make/380/bin/make: interrupt/Exception caught (code = 0xc0000005, addr = 0x417344) system() returned code 65280: exit code 255

As both mk and make 3.80 are big (and donât have a lot to do with Cygwin), I have spent some time narrowing down the problem.  I have produced a set of small files that produce the same error.  A very specific script structure is needed to reproduce the error (a bash script must call a perl script, which in turn must use back-ticks to run an executable that has a call to DuplicateHandle(Out)) (that is the same script structure that mk uses--and that causes DuplicateHandle(Out) to fail).  

Here are the 3 necessary files to reproduce the error (showProb.sh, showProb.pl, showProb.c):


showProb.sh: ###########################################
    #!/bin/sh
    perl -S showProb.pl



showProb.pl: ##########################################
  system("showProb.exe"); #this DupHandle works correctly
  $cwd = `pwd`; # This completes successfully
  system("showProb.exe"); #now DupHandle does _NOT_ work



showProb.c: ###########################################
  /*
  * Description: A very stripped-down version of process_easy in    
  * GNU make 3.80 (make/380/w32/subproc/sub_proc.c)
  */
  #include <stdlib.h>
 #include <stdio.h>
 #include <process.h>  /* for msvc _beginthreadex, _endthreadex */
 #include <windows.h>
 int main(){
  HANDLE hOut;
  if (DuplicateHandle(GetCurrentProcess(),
                      GetStdHandle(STD_OUTPUT_HANDLE),
                      GetCurrentProcess(),
                      &hOut,
                      0,
                      TRUE,
                      DUPLICATE_SAME_ACCESS) == FALSE) {
     
    fprintf(stderr, "\nprocess_easy: DuplicateHandle(Out) failed (e=%d)\n", GetLastError());
    /*return INVALID_HANDLE_VALUE;*/
  }
  else{
    fprintf(stderr, "\nprocess_easy: DuplicateHandle(Out) SUCCESS\n");
  }
  CloseHandle(hOut);
  return 0;
}



I used cl to compile showProb.c: âcl showProb.c âo showProb.exeâ.

I have done some experimenting with the above scripts/code.  The error is non-existent if the perl script or the executable is run alone (ie both DuplicateHandle calls complete successfully).  Only when the perl script is called from the bash script does DuplicateHandle stop working after the `pwd` call.

This problem did not occur in 1.5.6-1.  Is the system call in the back-ticks messing up the output handle in Cygwin 1.5.16?  Why does it only happen if the perl script is called from a bash script?  Is there something else happening?

Thanks for your time.


Nathan



Attachment: cygcheck.out
Description: Text document

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]