Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 63713

Summary: glibc/nptl deadlocks on programs with heavy threads usage
Product: Gentoo Linux Reporter: Canal Vorfeed <canalvorfeed>
Component: [OLD] Core systemAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: High    
Version: 2004.2   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---

Description Canal Vorfeed 2004-09-11 16:03:04 UTC
While investigating obscure mono bug #54603 (I wanted to play with mono and I have nptl-based gentoo installation) I've tried to reproduce deadlock without boehm's gc and without mono. Successfully. Simple programs (see below) deadlocks quite nicely).

Since threads are used in quite a few programs I think it's not some small mono problem anymore so I decided to create new, separe bugreport for it.

#include <pthread.h>
#include <stdio.h>

void *thread_function (void *args)
{
        int j = 0;
        char *str;
        printf("starting thread!\n");
        for (j; j < 24; j++)
        {
                str = (char *)malloc(240);
                printf("malloc in thread !\n");
        }
        pthread_yield();
}

int main (void)
{
        int i;
        pthread_t thread;
        char *str;
        for (i=0;i<1000;i++)
        {
                pthread_create( &thread, NULL, thread_function, (void *)i);
                pthread_yield();
                str = (char *)malloc(240);
                printf("%d threads\n", i);
        }
        sleep(10);
}

$ ./testpgm | grep 'malloc in thread' | wc -l
9168

Without ntpl I've got expected 24000 ...

Portage 2.0.50-r11 (default-x86-2004.2, gcc-3.3.4, glibc-2.3.4.20040808-r0, 2.6.9-rc1-mm4)
=================================================================
System uname: 2.6.9-rc1-mm4 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz
Gentoo Base System version 1.5.3
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.5-r1
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -pipe -march=pentium4 -funroll-loops -ffast-math -fomit-frame-pointer -ffloat-store -fforce-addr -ftracer -mmmx -msse -msse2 -mfpmath=sse"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -pipe -march=pentium4 -funroll-loops -ffast-math -fomit-frame-pointer -ffloat-store -fforce-addr -ftracer -mmmx -msse -msse2 -mfpmath=sse"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="ftp:///ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ ftp://vlaai.snt.ipv6.utwente.nl/pub/os/linux/gentoo/ ftp://ftp6.uni-erlangen.de/pub/mirrors/gentoo http://gentoo.spb.ru/rsync"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X apm arts avi berkdb bitmap-fonts crypt cups encode foomaticdb gdbm gif gnome gpm gtk gtk2 imlib jpeg kde libg++ libwww mad mikmod motif mpeg ncurses nls nptl oggvorbis opengl oss pam pdflib perl png python qt quicktime readline sdl slang spell ssl svga tcpd truetype x86 xml2 xmms xprint xv zlib"
Comment 1 Canal Vorfeed 2004-09-11 21:41:35 UTC

*** This bug has been marked as a duplicate of 63734 ***