delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/20/03:02:29

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
Subject: 1.5 unused error_start logic causes segfaults?
Date: Tue, 20 Oct 2009 09:02:06 +0200
MIME-Version: 1.0
From: "Matthias Andree" <matthias DOT andree AT gmx DOT de>
Message-ID: <op.u1265s1s1e62zd@balu.cs.uni-paderborn.de>
User-Agent: Opera Mail/10.00 (Win32)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Greetings,

the following programs will segfault on Cygwin 1.5 with GCC 3.4.4 and GCC  
4.3.2 UNLESS I define error_start program in $CYGWIN to contain  
error_start=C:\cygwin\bin\dumper.exe. If error_start is defined, the  
programs will abort as expected. With CYGWIN unset, the programs segfault.

The first will abort() properly on Cygwin 1.7/GCC 4.3.4 regardless of  
whether error_start is defined or not.

What has dumper or error_start got to do with crashes under Cygwin 1.5?  
Particularly, why does using dumper.exe "fix" the signal that the program  
receives when it doesn't catch the exception?

Any hopes of this getting fixed in Cygwin 1.5? Programs below.

Program 1 (C++):

// try-except.cc
// compile: g++-4 -Wall -W -O -o try-except try-except.cc
//      or: g++ -Wall -W -O -o try-except try-except.cc
int main() { throw("bad things happen"); }

Program 2 (C):

// try-abort.c
// compile: gcc-4 -Wall -W -O -o try-abort try-abort.c
//      or: gcc -Wall -W -O -o try-abort try-abort.c
#include <stdlib.h>
int main(void) { abort(); }


Now note the "Segmentation fault" vs. "Aborted" below:

$ unset CYGWIN
$ ./try-except.exe
Segmentation fault (core dumped)
$ ./try-abort.exe
Segmentation fault (core dumped)

$ export CYGWIN='error_start=c:\cygwin\bin\dumper.exe'
$ ./try-except.exe
*** starting debugger for pid 2680, tid 1464
*** continuing pid 2680 from debugger call (1)
Aborted (core dumped)
$ ./try-abort.exe
*** starting debugger for pid 2900, tid 5796
*** continuing pid 2900 from debugger call (1)
Aborted (core dumped)

Oh, and let's try to set error_start to something that isn't an executable  
program:

$ export CYGWIN='error_start=C:\'
$ ./try-except.exe
terminate called after throwing an instance of 'char const*'
*** starting debugger for pid 5688, tid 3752
       7 [sig] try-except 5112 try_to_debug: Failed to start debugger,  
Win32 error 3
*** continuing pid 5688 from debugger call (0)
Segmentation fault (core dumped)


Might the error_start logic be broken on Cygwin 1.5, meaning that any  
signal causing program termination runs bad code in the Cygwin DLL? This  
bad code appears to cause a segfault instead of the original signal unless  
a debugger can properly attach.

$ uname -r
1.5.25(0.156/4/2)

On Windows XP Version 2002 Tablet PC Edition 2005 Service Pack 3.

-- 
Matthias Andree

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019