From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214 Description of problem: Run the attached program a couple of times. Roughly half of the times one of the lines is printed twice, or some characters aren't printed at all. I have tried it on three separate machines, a single CPU x86 Debian Testing one, a 2 CPU x86 with RH7.1, and another single CPU x86 with RH6.2. All three machines have similar problems. I also have problems with crashes when using clone() and printf() together that may be related to this, but I'll report that separately when I can provoke it with a short example program. Version-Release number of selected component (if applicable): glibc-2.2.4-19.3 How reproducible: Sometimes Steps to Reproduce: gcc cloneprintfrace.c ./a.out Actual Results: Varying, but here's one bogus one. Note that the first line is printed twice. Parent 30785: This is a random printout Parent 30785: This is a random printout Child 30786: Hello Child 30786: Good bye Expected Results: Parent 31394: This is a random printout Child 31395: Hello Child 31395: Good bye Additional info: This bug has been reported in Debian's bug reporting system as well, at "http://bugs.debian.org/140155". Based on blind guessing however, I recon you may be faster at fixing these kinds of problems.
Created attachment 50864 [details] 40 line C program illustrating the problem
This is not a glibc bug. If you are using clone directly (as opposed to using pthread_create), you're responsible for locking too. printf (well, not only that) is thread safe because it uses pthread_mutex* etc. If you don't want to use -lpthread, you either need to write a threading library of your own which will at least provide the locking semantics glibc need, or use some locking around all calls you make into foreign libraries which need thread safety.