From: "Jay P. Elston" <jay.elston@oemgroupinc.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: How can I determine why gdb throws unknown exceptions when debugging programs with threads on my Cygwin installation?
Date: Wed, 23 Oct 2019 17:25:00 -0000 [thread overview]
Message-ID: <b0f98e400a8e4787b3e8b0b14a7a9baa@OEM26.oemsurplus.local> (raw)
Hi all,
I developed a problem debugging threads on my Cygwin installed on a Window 7 PC -- gdb throws an unknown target exception when it gets to the pthread_crreate() call.
This problem seems localized to my PC (even after reinstalling Cygwin), and I am wondering what my next trouble shooting steps might be.
Here are the relevant lines from the gdb session:
$ gdb a.exe
GNU gdb (GDB) (Cygwin 8.1.1-1) 8.1.1
. . .
This GDB was configured as "x86_64-pc-cygwin".
. . .
Reading symbols from a.exe...done.
(gdb) run
Starting program: /home/jay.elston/threadTest/a.exe [New Thread 12908.0xc38] [New Thread 12908.0x25b4] [New Thread 12908.0x182c] [New Thread 12908.0x2958] [New Thread 12908.0x2ce4] [New Thread 12908.0x2878] [New Thread 12908.0x3044]
gdb: unknown target exception 0x80000001 at 0x778e7b97
Thread 7 received signal ?, Unknown signal.
[Switching to Thread 12908.0x3044]
0x00000000778e7b97 in ntdll!RtlAllocateHeap ()
from /cygdrive/c/Windows/SYSTEM32/ntdll.dll
(gdb) c
Continuing.
[Thread 12908.0x182c exited with code 2147483649] [Thread 12908.0x25b4 exited with code 2147483649] [Thread 12908.0x2878 exited with code 2147483649] [Thread 12908.0x2958 exited with code 2147483649] [Thread 12908.0x2ce4 exited with code 2147483649] [Inferior 1 (process 12908) exited with code 020000000001]
I discovered this problem last week, and wrote a very simple thread program (see listing of threads.c below), which I compiled, ran, and tried running under gdb with the commands:
$ gcc -g threads.c
$ ./a.exe
$ gdb a.exe
I suspected that maybe my Cygwin installation has "gone bad", so I removed Cygwin, rebooted, and put a fresh Cygwin install on my pc. (I did this by rebooting in safe mode, getting the latest version of setup-x86_64.exe and running the setup program as Administrator.) Alas, I still cannot debug threads :-(
I can do a directory listing of the dll where the exception is thrown:
$ ls -l /lib/w32api/libntdll.a
-rw-r--r-- 1 jay.elston Domain Users 1552334 Jun 8 2018 /lib/w32api/libntdll.a
Here is some version information:
$ uname -a
CYGWIN_NT-6.1 M4800-1RBTK12 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
$ gdb -v
GNU gdb (GDB) (Cygwin 8.1.1-1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix gcc version 7.4.0 (GCC)
Here is the simple program:
threads.c:
// Start a thread using pthread_create
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <pthread.h>
void *fifteenSeconds(void *arg)
{
struct timespec sleepTime;
struct timespec sleptTime;
int i = 0;
while ( i++ < 2 ) {
printf("%d\n", i);
sleepTime.tv_sec = 01;
sleepTime.tv_nsec = 000000000;
nanosleep(&sleepTime, &sleptTime);
}
return (void *)0;
}
int main ( int argc, char *argv[] )
{
pthread_t fifteenSecondsThreadId;
int rc = 0;
rc = pthread_create(&fifteenSecondsThreadId, (void *)0, &fifteenSeconds, (void *)0);
if ( rc != 0 ) {
fprintf(stderr, "(%s,%d): Error %d creating thread for io handler: %s\n"
, __FILE__, __LINE__
, errno, strerror(errno)
);
return rc;
}
pthread_join(fifteenSecondsThreadId, (void *)0);
return 0;
}
Jay
--
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
next reply other threads:[~2019-10-23 17:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 17:25 Jay P. Elston [this message]
2019-10-25 13:32 ` Jon Turney
2019-10-25 13:49 ` Soegtrop, Michael
2019-10-26 2:34 ` Jay P. Elston
2019-10-26 3:20 ` Brian Inglis
2019-10-28 8:40 ` Soegtrop, Michael
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b0f98e400a8e4787b3e8b0b14a7a9baa@OEM26.oemsurplus.local \
--to=jay.elston@oemgroupinc.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).