delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/06/20/16:02:55

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:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=uT
F0XJIkgNS8vqxJSHNJ+NlnIrgSmTKWYQ5lG7dFjdQmvO4ADiQfENA5zAZZKzdJ19
kAduOapUOISQKVZII4YD5jfPZIM331wPLJdLNZmBs8o2z2DaYwesnBs3KkVCeJUk
IUzxSAaBW446xhvxB/rZgPGzgu95/5Hp9QT0/cz9s=
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:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=jxRYuJdB
3WdpNEahqurHvK6dCDc=; b=gxjx0IBwUq4u4m8QTEZp2wYIDPTmKx6jBjPDb5hN
IrGNOKnQWn+dbgI7Z2OlTyQdSXyMfFhHoONDJgLMg9ipyr05ZZvkpdRkDFj6hvet
8OaX5Zih3EtDTT3EcvaEkKbPxsNdHcnNhHNHs4VcySCHPrl9yTsbbgmERz9Z1AIo
LnU=
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-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-yh0-f45.google.com
MIME-Version: 1.0
X-Received: by 10.170.161.85 with SMTP id c82mr27430902ykd.33.1434830558483; Sat, 20 Jun 2015 13:02:38 -0700 (PDT)
In-Reply-To: <20150620184715.GA17350@calimero.vinschen.de>
References: <CAH5rLZVsTzSVTRzG_Aucw=_i-o5M-G0_ddPu0gPaqQM-Nn3iJg AT mail DOT gmail DOT com> <20150620184715 DOT GA17350 AT calimero DOT vinschen DOT de>
Date: Sat, 20 Jun 2015 16:02:38 -0400
Message-ID: <CAH5rLZXbYNUwB_f2Vigev--NsmB3FrdhWre1uYxAr0ckN8NvmQ@mail.gmail.com>
Subject: Re: gdb arbitrarily starting threads
From: "William M. (Mike) Miller" <william DOT m DOT miller AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On Sat, Jun 20, 2015 at 2:47 PM, Corinna Vinschen
<corinna-cygwin AT cygwin DOT com> wrote:
> On Jun 20 09:29, William M. (Mike) Miller wrote:
>> 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]
>
> You don't have this under control.  Nor does Cygwin, most of the time.
>
> E.g, a debugged Windows executable has always at least two threads, one
> is your process thread, one is the thread created by the OS when the
> debugger attaches to a process.
>
> Every Cygwin process has at least two threads, your process thread, as
> well as a so-called "signal thread", the thread handling POSIX signals,
> created at every process startup by the Cygwin DLL.
>
> Certain Windows system calls create threads in your process to perform
> tasks "under the hood".
>
> Cygwin is doing the same, for instance to implement interruptible system
> calls where the underlying OS call is non-interuptible.  select(2) may
> start multiple threads at once.  Etc.
>
> There's no way around that.  Windows process handling is centered around
> cheap thread creation and termination.  Have a look into the "Details"
> view in Windows Task Manager.  Activate the "Threads" column.  Note that
> almost all processes are running with more than one thread.  Just don't
> worry about it, it's kind of system inherent.

Thanks for the reply.  My concern, however, isn't that new threads are
being created; it's that when gdb does this, it sets the state of all
threads, including my main thread, to "(running)" so that I can't
single-step through my program any more.  If I try to say "next", I
get the error:

    Cannot execute this command while the selected thread is running.

But I did nothing overt to start my thread.

It never used to do this, but it happens regularly now.

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

- Raw text -


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