[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#140155: marked as done (libc6: printf() + shared memory = race condition)



Your message dated Sat, 24 Aug 2002 23:20:38 +1000
with message-id <20020824132038.GA31463@gondor.apana.org.au>
and subject line dont use clone with printk
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 27 Mar 2002 14:13:21 +0000
>From johan@appeal.se Wed Mar 27 08:13:21 2002
Return-path: <johan@appeal.se>
Received: from (bortas.appeal.se) [195.22.77.29] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 16qEAz-0003s2-00; Wed, 27 Mar 2002 08:13:21 -0600
Received: from barbara (barbara.appeal.se [192.168.1.70])
	by bortas.appeal.se (8.11.0/8.11.0) with ESMTP id g2RECnw32368
	for <submit@bugs.debian.org>; Wed, 27 Mar 2002 15:12:49 +0100
Received: from johan by barbara with local (Exim 3.35 #1 (Debian))
	id 16qEAO-00018D-00; Wed, 27 Mar 2002 15:12:44 +0100
From: Johan Walles <johan@appeal.se>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: libc6: printf() + shared memory = race condition
X-Mailer: reportbug 1.48
Date: Wed, 27 Mar 2002 15:12:44 +0100
Message-Id: <E16qEAO-00018D-00@barbara>
Delivered-To: submit@bugs.debian.org

Package: libc6
Version: 2.2.5-3
Severity: normal

Run the below 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; this 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.

According to the libc info page about "Streams and Threads", "issuing
two stream operations for the same stream in two threads at the same
time will cause the operations to be executed as if they were issued
sequentially.".  For me, that is obviously not the case.

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.

"
#include <stdio.h>
#include <sched.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/types.h>

int childfunc(void *arg)
{
   assert(printf("Child %d: Hello\n", getpid()) >= 0);
   assert(printf("Child %d: Good bye\n", getpid()) >= 0);

   return 0;
}

int main(int argc, char *argv[])
{
   const size_t stacksize = 65536;
   
   pid_t cloneResult;
   int cloneErrno;
   
   void *stack = malloc(stacksize);
   
   cloneResult = clone(childfunc,
                       stack + stacksize,
                       CLONE_VM| CLONE_FILES,
                       (void *)0xDeadf00d);
   cloneErrno = errno;
   
   if (cloneResult <= 0) {
      perror("Clone() failed");
      exit(EXIT_FAILURE);
   }

   assert(printf("Parent %d: This is a random printout\n", getpid()) >= 0);
  
   return 0;
}
"

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux barbara 2.4.16-686 #1 Wed Nov 28 09:27:17 EST 2001 i686
Locale: LANG=sv_SE.ISO-8859-1, LC_CTYPE=sv_SE.ISO-8859-1


---------------------------------------
Received: (at 140155-done) by bugs.debian.org; 24 Aug 2002 13:20:44 +0000
>From herbert@gondor.apana.org.au Sat Aug 24 08:20:44 2002
Return-path: <herbert@gondor.apana.org.au>
Received: from eriador.apana.org.au [203.14.152.116] (mail)
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 17iaqJ-0006Ng-00; Sat, 24 Aug 2002 08:20:44 -0500
Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail)
	by eriador.apana.org.au with esmtp (Exim 3.12 #1 (Debian))
	id 17iaqE-0006m1-00
	for <140155-done@bugs.debian.org>; Sat, 24 Aug 2002 23:20:38 +1000
Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.35 #1 (Debian))
	id 17iaqE-0008Bv-00
	for <140155-done@bugs.debian.org>; Sat, 24 Aug 2002 23:20:38 +1000
Date: Sat, 24 Aug 2002 23:20:38 +1000
To: 140155-done@bugs.debian.org
Subject: dont use clone with printk
Message-ID: <20020824132038.GA31463@gondor.apana.org.au>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.4i
From: Herbert Xu <herbert@gondor.apana.org.au>
Delivered-To: 140155-done@bugs.debian.org

Using printk with a direct clone leads to undefined behaviour.
-- 
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



Reply to: