delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/16/14:14:29

X-Spam-Check-By: sourceware.org
Message-ID: <4492F4F2.1070908@cygwin.com>
Date: Fri, 16 Jun 2006 14:14:10 -0400
From: "Larry Hall (Cygwin)" <reply-to-list-only-lh AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20060112 Fedora/1.5-1.fc4.remi Thunderbird/1.5 Mnenhy/0.7.4.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Segmentation fault when debugging C++ with gdb.
References: <EB9F423ED26F2747947B3CEE6241B6D5B181F3 AT srvsund01 DOT tritech DOT se>
In-Reply-To: <EB9F423ED26F2747947B3CEE6241B6D5B181F3@srvsund01.tritech.se>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

Mikael Rosbacke wrote:
> Hello!
> 
> I'm having problem to debug my C++ programs using GDB under cygwin. I
> get a seg-fault in the c-startup before the main function has been
> started.
> 
> The following test program is used:
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$ more
> /cygdrive/c/testcase/test.cpp
> 
> #include <iostream>
> #include <string>
> 
> int main()
> {
>     std::string t;
> 
>     std::cout << "Hello world!" << std::endl;
>     std::cin >> t;
>     std::cout << "Hello " << t << "!" << std::endl;
> }
> 
> Trying to compile and run this program in cygwin give me the following
> result:
> 
> 
> mikaelr AT MSUNDMIKAELR2 ~$ cd /cygdrive/c/testcase/
> 
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$ ls
> a.exe  test.cpp  test.cpp~
> 
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$ /bin/g++ -v
> Reading specs from /bin/../lib/gcc/i686-pc-cygwin/3.4.4/specs
> Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose
> --prefix=/usr --
> exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
> --libexecdir=/usr/lib --man
> dir=/usr/share/man --infodir=/usr/share/info
> --enable-languages=c,ada,c++,d,f77,
> java,objc --enable-nls --without-included-gettext
> --enable-version-specific-runt
> ime-libs --without-x --enable-libgcj --disable-java-awt
> --with-system-zlib --ena
> ble-interpreter --disable-libgcj-debug --enable-threads=posix
> --enable-java-gc=b
> oehm --disable-win32-registry --enable-sjlj-exceptions
> --enable-hash-synchroniza
> tion --enable-libstdcxx-debug : (reconfigured)
> Thread model: posix
> gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
> 
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$ /usr/bin/g++ -g test.cpp
> 
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$ /bin/gdb a.exe
> GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "i686-pc-cygwin"...
> (gdb) run
> Starting program: /cygdrive/c/testcase/a.exe
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x610ae938 in pthread_key_create () from /usr/bin/cygwin1.dll
> (gdb) bt
> #0  0x610ae938 in pthread_key_create () from /usr/bin/cygwin1.dll
> #1  0x6108dd7f in _sigfe () from /usr/bin/cygwin1.dll
> #2  0x59432d52 in ?? ()
> #3  0x004ce348 in ?? ()
> #4  0x004ce31b in ?? ()
> #5  0x004ce348 in ?? ()
> #6  0x0022edc8 in ?? ()
> #7  0x610af6b7 in pthread::once () from /usr/bin/cygwin1.dll
> #8  0x610af6b7 in pthread::once () from /usr/bin/cygwin1.dll
> #9  0x6108dd7f in _sigfe () from /usr/bin/cygwin1.dll
> #10 0x0022edf8 in ?? ()
> #11 0x0040f5c5 in _Unwind_SjLj_Register ()
>     at /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream:77
> #12 0x0040f5c5 in _Unwind_SjLj_Register ()
>     at /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream:77
> #13 0x004011a4 in main () at test.cpp:6
> (gdb) exit
> Undefined command: "exit".  Try "help".
> (gdb) quit
> The program is running.  Exit anyway? (y or n) y
> 
> mikaelr AT MSUNDMIKAELR2 /cygdrive/c/testcase$
> 
> Seems like the initialization of the static iostream objects causes the
> seg-fault.
>  
> 
> I've tried to download gcc version 4.0 and a new gdb as tarballs and
> compiled it from source. Using these tools it seems to work. But it is
> not a good solution for us to have a separate compiler from the rest of
> the distribution. Any ideas how to fix this?

Yes.  Start by checking the email archives for previous discussions of this
issue.  Sounds to me like you have half the real solution already (gdb
sources, presumably from CVS).  Grab the latest Cygwin DLL snapshot and
you're done.  Otherwise, live with typing "c <return>" as many times as
necessary until you're by the problem.

In case it's not clear from the above, this has been talked to death on this
list so if you have any thoughts about re-opening this subject for discussion,
you better wear your flame-resistant suit!



-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746

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

- Raw text -


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