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

Bug#681113: libpthread breaks pipe buffer



Package: libc0.1
Version: 2.13-34
Severity: serious


Hello!,

On a Debian/KFreeBSD 64-bits system (sid)


debian-kfreebsd ~ # uname -a
GNU/kFreeBSD debian-kfreebsd 9.0-1-amd64 #0 Fri Jun 15 21:15:10 UTC 2012 x86_64 amd64 QEMU Virtual CPU version 1.0 GNU/kFreeBSD




See the following behavior:


cat > testbuf.c << EOF
#include <stdio.h>
#include <pthread.h>

void *f1(){
  sleep(1);
  printf("Inside thread1\n");
  pthread_exit(0);
}

void *f2(){
  sleep(1);
  printf("Inside thread2\n");
  pthread_exit(0);
}

main()  {

  pthread_t f2_thread, f1_thread;
  void *f2(), *f1();

  printf ("Going to start thread1 ond thread2...\n");
  pthread_create(&f1_thread,NULL,f1,NULL);
  pthread_create(&f2_thread,NULL,f2,NULL);
  pthread_join(f1_thread,NULL);
  pthread_join(f2_thread,NULL);

}
EOF


debian-kfreebsd ~ # gcc -lpthread testbuf.c -o testbuf


debian-kfreebsd ~ # ./testbuf
Going to start thread1 ond thread2...
Inside thread1
Inside thread2


debian-kfreebsd ~ # ./testbuf | cat
                                      <<------------(nothing outputs)


debian-kfreebsd ~ # ./testbuf | wc -l
0


However this don't happens every-time, sometimes it works, sometimes it don't works. See this:

debian-kfreebsd ~ # for x in $(seq 1 20); do ./testbuf | wc -l; done
3
3
3
3
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0


But, if you run the program with "stdbuf -oL" it handles the pipe buffer as expected every-time:

debian-kfreebsd ~ # for x in $(seq 1 20); do stdbuf -oL ./testbuf|wc -l; done
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3


Needless to say that this only happens on Debian/KFreeBSD.

Neither on Debian/Linux nor in Debian/Hurd this behavior is reproducible.

Regards!
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Carlos Alberto Lopez Perez                           http://neutrino.es
Igalia - Free Software Engineering                http://www.igalia.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: