delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/10/23/13:26:44

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; q=dns; s=default; b=sUC
y7rBA2C4yUnYXqCKmRJp9Zxscy4Ic10nqTne4woQY8z9XbXVhezim92Y6p/oq9iF
0qM1lAENmc9wxnBie9K/Q0p0cP2DriEmH+72PRTQ3YESueTrvlqbKbYLxLPbEj7L
WquNd+tCEC83cuy5sSMUDfPUmO+imonk8yG1jQ/4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; s=default; bh=6F06EbQ00
Y7LrjpoU86pUulZFGY=; b=SjCnos9hal/prGEv4YK6atcpGq+VfmTrGgH7VZfDu
XlKunjo1j7aaN8yBUBUlIhf98qif2qV+lDa2SUjz7LyPen2MOn5JyrfGHmBk1CD5
mVtSJ42h46E72K/CkKLnB/3FIwSld2Y+Vhp1bI6YItfXHYlQUyUCKO+Xx+lRkj6u
EI=
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
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.1 spammy=
X-HELO: mailgate.oemgroupinc.com
From: "Jay P. Elston" <jay DOT elston AT oemgroupinc DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT 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:51 +0000
Message-ID: <b0f98e400a8e4787b3e8b0b14a7a9baa@OEM26.oemsurplus.local>
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x9NHQQhE027370

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


- Raw text -


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