This is the mail archive of the cygwin-patches 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]

Re: [PATCH] Prevent restart of crashing non-Cygwin exe


Christopher Faylor wrote:
On Thu, Nov 03, 2011 at 01:07:20PM +0100, Corinna Vinschen wrote:
On Nov 2 20:53, Christian Franke wrote:
On Jun 24, Corinna Vinschen wrote:
Hi Christian,

On Jun 23 19:52, Christian Franke wrote:
If a non-Cygwin .exe started from a Cygwin shell window segfaults,
Cygwin restarts the .exe 5 times.
[...l]
	* sigproc.cc (child_info::sync): Add exit_code to debug
	message.
	(child_info::proc_retry): Don't retry on unknown exit_code
	from non-cygwin programs.
This looks ok to me, but cgf should have a say here.  He's on vacation
for another week, though.

Problem can still be reproduced with current CVS.  Patch is still
valid.
Sorry, I forgot about this patch entirely.  Chris, is that patch ok
with you as well?
No, it isn't.  Sorry for not stating this earlier.  The problem that
this code was intended to solve was actually a transient exit codes from
a non-Cygwin process which began with 0xc...

I don't believe that I ever saw STATUS_ACCESS_VIOLATION in any of my
testing though so adding that earlier in the switch would fix this
particular problem.  I'll do that.

Works as expected with testcase from my first mail:


$ i686-w64-mingw32-gcc -o crash-w crash.c

$ ./crash-w
Hello,


A drawback is that non-Cygwin programs crash silently. I attached an experimental patch which sets WTERMSIG(status) = SIGSEGV:

$ ./crash-w
Hello, Segmentation fault

Christian

diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 5a77d8f..7d60d62 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -148,9 +148,13 @@ status_exit (DWORD x)
 void
 pinfo::set_exit_code (DWORD x)
 {
-  if (x >= 0xc0000000UL)
+  int sig = sigExeced;
+  if (x == STATUS_ACCESS_VIOLATION && !sig)
+    /* Report segfault to parent process.  */
+    sig = SIGSEGV;
+  else if (x >= 0xc0000000UL)
     x = status_exit (x);
-  self->exitcode = EXITCODE_SET | (sigExeced ?: (x & 0xff) << 8);
+  self->exitcode = EXITCODE_SET | (sig ?: (x & 0xff) << 8);
 }
 
 void

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