delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/01/09/09:25:28

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 9 Jan 2013 15:24:31 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: [bug?] 2nd printf output gets gobbled up when 1st used in a thread
Message-ID: <20130109142431.GA19797@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAAY4zx_vkqyAJj8AH89dhO6jjjFffu5RoVgpB3tEcHcxH1NGFg AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CAAY4zx_vkqyAJj8AH89dhO6jjjFffu5RoVgpB3tEcHcxH1NGFg@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Jan  1 16:16, furrylogical wrote:
> Hello everyone,
> 
> Cygwin seems to behave strangely when `printf` is used in threads: if
> the first `printf` encountered occurs in another thread, then the
> first `printf` that occurs in the main function will vanish into thin
> air.  The following fragment illustrates this:
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> 
> void *func(void *arg)
> {
>     printf("thread_printf\n");
>     return NULL;
> }
> 
> int main(int argc, char **argv)
> {
>     pthread_t thread;
>     pthread_create(&thread, NULL, func, NULL);
>     pthread_join(thread, NULL);
>     printf("main_printf1\n");           /* This line never gets printed */
>     printf("main_printf2\n");
>     return 0;
> }
> 
> When compiled with `gcc` with no options, the output is:
>   thread_printf
>   main_printf2
> 
> I'm not familiar with the Cygwin codebase.  If someone can point me in
> the right direction, I might be able to figure out what is causing
> this issue.
> 
> I appreciate the if someone can help me figure this out, though I
> understand it's not exactly a critical issue.  Thanks all.

Thanks for the testcase.  I could easily reproduce this issue and
track down the cause.  I checked in a patch.  Please give the next
developer snapshot from http://cygwin.com/snapshots/ a try.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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