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:mime-version:date:message-id:subject:from:to :content-type; q=dns; s=default; b=eah6Mnj1dpc6bxUvP2bUIq9uogYtH lQ+qgEH9DAfhXYjXvEc5Ir/lLIQOvOUm1OuYKpRGa2TGHlF5PRg35Q5EqeqlCkOp 7z+blV93NL9ilLCzf/wBYtkKd4mle2r+EFeH9hJMr9R1QJDZh9UDNpO3QJ2Mzqwa 4ctVCFJqGX6uyw= 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:mime-version:date:message-id:subject:from:to :content-type; s=default; bh=zeqQuMhhDVGVaWQS3O6ajcFUAis=; b=qoI YiblMn0o+M6vNi9benghz+HAkF9izqKrGyGa4igmar1gp2CnjFt4wSOHaMLfS/1l ZmJC/f/Uw/qQALEdKnGTm1JgtjUwevVBhNfXSQNBk6DpfR5cEoA1we2mgUvXLnp6 2VaCOaVajYkPjXUeaaYxSN0yG/fvLoiuijTLQBYg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f53.google.com MIME-Version: 1.0 X-Received: by 10.129.110.68 with SMTP id j65mr25782175ywc.86.1434806951476; Sat, 20 Jun 2015 06:29:11 -0700 (PDT) Date: Sat, 20 Jun 2015 09:29:11 -0400 Message-ID: Subject: gdb arbitrarily starting threads From: "William M. (Mike) Miller" To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes I have a single-threaded executable that has a number of debug-print routines that can be called interactively in the debugger to display data structures to stderr. Something has changed in gdb/gcc/Cygwin during the last year or so (I don't update my installation very often) so that when I call one of these functions, _sometimes_ gdb will start a new thread and put my current thread into "running" status, so that I can't step, etc. (although the thread isn't actually running). Here's the scenario: 1) I say "gdb xxx.exe", set a breakpoint, and run. When I hit the breakpoint, "info threads" shows me two threads, one for my executable and one with some _cygtls/cygthread/ntdll frames; both are stopped. 2) I say "up" a couple of times, then "p db_foo(p)" (where db_foo is one of these debug-print routines that displays to stderr the data structure pointed to by "p"). Sometimes, but not always, gdb will respond with [New Thread 1436.0x1f00] and although a "bt" will show the stack as still stopped at the breakpoint, "info threads" will show all threads as "(running)", and typing "n" is met with the error, Cannot execute this command while the selected thread is running. (Actually, for the first time just now, while running my scenario to make sure I got all the details right for this email, I saw gdb start a new thread in response to a "next" command -- (gdb) n [New Thread 1436.0x1a0c] after I had done a "p db_foo(p)" a couple of times without seeing a new thread created, so apparently it's not just invoking one of these debug-print functions that can result in this behavior.) Changing to one of the newly-created threads reveals this stack trace: #0 0x7733df6c in ntdll!ZwWaitForWorkViaWorkerFactory () from /c/WINDOWS/SYSTEM32/ntdll.dll #1 0x77320153 in ntdll!RtlRunOnceBeginInitialize () from /c/WINDOWS/SYSTEM32/ntdll.dll #2 0x6100626b in _cygtls::call2(unsigned long (*)(void*, void*), void*, void*) () from /usr/bin/cygwin1.dll #3 0x61006306 in _cygtls::call(unsigned long (*)(void*, void*), void*) () from /usr/bin/cygwin1.dll #4 0x610828d8 in threadfunc_fe(void*) () from /usr/bin/cygwin1.dll #5 0x74be7c04 in KERNEL32!BaseThreadInitThunk () from /c/WINDOWS/SYSTEM32/KERNEL32.DLL #6 0x7735ad1f in ntdll!RtlInitializeExceptionChain () from /c/WINDOWS/SYSTEM32/ntdll.dll #7 0x7735acea in ntdll!RtlInitializeExceptionChain () from /c/WINDOWS/SYSTEM32/ntdll.dll #8 0x00000000 in ?? () Any ideas on what I can do to avoid this annoying behavior or to regain control of my debugging session after it occurs? I'm running 32-bit Cygwin on Windows 8.1. Thanks. -- William M. (Mike) Miller | Edison Design Group william DOT m DOT miller AT gmail DOT com -- 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