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]

Re: Segmentation fault when exception is thrown or assertion fails [g++/gcc]


Roman Werpachowski wrote:
> Some more details about my problem
> (http://cygwin.com/ml/cygwin/2009-07/msg00150.html)
> 
> $ gcc -v

  Actually even more useful would be to know what Cygwin DLL version you're
running.  The problems page that CGF directed you to contains in particular
the advice to run "cygcheck -s -v -r > cygcheck.out" and then send the
cygcheck.out file ** as an attachment, not inline, please ** to the list with
your post.

  From your earlier post:

> I understand that Cygwin defaults to dumping the stack trace, but why
> the message about segmentation fault? It confuses the hell out of me.

  Well, what happened was that there's a bug somewhere, and while cygwin was
in the process of dumping the stack trace for the abort caused by your
assertion firing, the DLL itself had a segfault, and had to give up.  It said
"probably corrupted stack", because that's the most common reason why you
might end up following a stray pointer and causing a segfault when you were
trying to unwind the stack, but in this case it's unlikely anything would have
corrupted the stack, so either there's a real bug or perhaps just some kind of
frame-pointer optimisation that confuses the unwind routine.

  I tried your example with both gcc-4 and gcc-3 on current 1.7 and it worked
just fine:

> $ cat ass.c
> #include <assert.h>
> 
> int main(void)
> {
>     assert( 1 == 0 );
>     return 0;
> }
> 
> $ gcc -g -O0 ass.c -o ass
> 
> $ ./ass.exe
> assertion "1 == 0" failed: file "ass.c", line 5, function: main
> Aborted (core dumped)
> 
> $ ls
> ass.c  ass.exe  ass.exe.stackdump
> 
> $ cat ass.exe.stackdump
> Stack trace:
> Frame     Function  Args
> 0022CAF8  7C4F1B1B  (00000000, FFFFFFFF, 0022CC28, 00000000)
> 0022CBD8  610B5527  (00000000, 00000000, 00000000, 00000000)
> 0022CC28  610B593B  (00000634, 0022CC50, 77F891D2, 000003D0)
> 0022CCE8  610B5A61  (00000634, 00000006, 0022CD18, 610B5B05)
> 0022CCF8  610B5A9C  (00000006, 0022CE88, 6115444C, 00000101)
> 0022CD18  610B5B05  (61158054, 00402085, 0040208C, 00000005)
> 0022CD48  6100109B  (0040208C, 00000005, 00402080, 00402085)
> 0022CD68  610B2CB8  (6127EE7E, 00000000, 0022CDA8, 61006E4A)
> 0022CDA8  61006E4A  (00000000, 0022CDE0, 61006720, 7FFDF000)
> End of stack trace

  I also tried at -O2, same results.

    cheers,
      DaveK


--
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


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