delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/05/07/16:22:51

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: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 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
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 DOT johnson AT cs DOT utoronto DOT 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 AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: printf + pthreads+gdb+mintty = hang?
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--

- Raw text -


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