X-Recipient: archive-cygwin@delorie.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:message-id:date:from:mime-version:to:subject
	:content-type; q=dns; s=default; b=POYhTC6AgC0hAJtfbbY+Cw+9rWMIP
	7s2N9o9lslShcQLwIhxzjsHxhUMBCp+gAArZUjiKUtzrfATkTZ9/nnWD0wfx4il8
	t48qL0UhNH0MQvG1n5lE2m9qaB45OZjL55AA/lJc0B8mvwI3BB0B+9l0S/6XkkT/
	WGWwFi6C2wIJr8=
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:message-id:date:from:mime-version:to:subject
	:content-type; s=default; bh=Jq9oEWQ2tE9AqYYIdUfKL76FMvs=; b=sF2
	W4aGv9mQyLoKIZrU0h5mfNE+Fw6TcN2Bz2RnSWM2+YleCKmidCxyHTKSl1GZGgxV
	G1SJLrIqNGiBhimRpOg8rjEAPBouxm07RnT/wQQgkN5aanOSt9AioTgyrTvQxZzS
	cRWRbjXTD4dxXS4cnashz5meqfI+u58DEjFkeS8g=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_NEUTRAL autolearn=ham version=3.3.1
Message-ID: <5189627F.3050801@cs.utoronto.ca>
Date: Tue, 07 May 2013 16:22:23 -0400
From: Ryan Johnson <ryan.johnson@cs.utoronto.ca>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version: 1.0
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: printf + pthreads+gdb+mintty = hang?
Content-Type: multipart/mixed; boundary="------------000105000104060707010404"
X-Virus-Found: No

--------------000105000104060707010404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi all,

Running the attached STC inside gdb hangs (zero CPU util, have to kill 
gdb from Task Manager, killing a.exe doesn't cut it).

Compile line used: g++ -Wall -g -mthreads -DBUG bug.cpp

I currently have the following package versions:
cygwin-1.7.18(0.263/5/3) 2013-04-19
mintty-1.1.3-1
gdb-7.6.50-1
gcc-4.5.3-3

The problem seems to be related to threads calling fprintf inside gdb, 
it runs fine from the command line, or with printf instead; both fprintf 
and printf sometimes trigger "warning: SuspendThread failed. (winerr 6)" 
(not sure if that matters).

Known issue? Easy workaround? New bug?

Thanks,
Ryan


--------------000105000104060707010404
Content-Type: text/plain; charset=windows-1252;
 name="bug.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="bug.cpp"

#include <stdio.h>
#include <pthread.h>

#if BUG
#define P(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
#define P(fmt, ...) printf(fmt, ##__VA_ARGS__)
#endif

void* go(void *arg) {
    long tid = (long)arg;
    P("Thread %ld started\n", tid);
    for (int i=0; i < 100; i++) 
        P("%ld\n", tid+i);
    P("Thread %ld exited\n", tid);
    return 0;
}

int main() {
    int tcount = 3;
    pthread_t tids[tcount];
    for (int i=0; i < tcount; i++)
        pthread_create(&tids[i], 0, &go, (void*)(1000*i));
    for (int i=0; i < tcount; i++)
        pthread_join(tids[i], 0);
    return 0;
}


--------------000105000104060707010404
Content-Type: text/plain; charset=us-ascii

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