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 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: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 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 > #include > #include > > 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