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

Bug#233846: marked as done (pthread_mutex_lock/unlock problem)



Your message dated Fri, 12 Mar 2004 15:58:34 +0900
with message-id <81n06mzh45.wl@omega.webmasters.gr.jp>
and subject line Bug#233846: pthread_mutex_lock/unlock problem
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; 20 Feb 2004 09:59:18 +0000
>From strycek@posam.sk Fri Feb 20 01:59:18 2004
Return-path: <strycek@posam.sk>
Received: from fernet.posam.sk [62.168.66.66] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1Au7RG-0002GR-00; Fri, 20 Feb 2004 01:59:18 -0800
Received: by fernet.posam.sk (Postfix, from userid 65534)
	id 4E953520C5; Fri, 20 Feb 2004 10:59:02 +0100 (CET)
Received: from smtpmta.posam.sk (unknown [172.16.0.6])
	by fernet.posam.sk (Postfix) with ESMTP id 0B770520C5
	for <submit@bugs.debian.org>; Fri, 20 Feb 2004 10:59:02 +0100 (CET)
To: submit@bugs.debian.org
Subject: pthread_mutex_lock/unlock problem
MIME-Version: 1.0
X-Mailer: Lotus Notes Release 6.0.1 February 07, 2003
Message-ID: <OF286B2CA5.ABDB7E64-ONC1256E40.00324CD6-C1256E40.0036DCEB@smtpmta.posam.sk>
From: Robert Strycek <strycek@posam.sk>
Date: Fri, 20 Feb 2004 10:59:14 +0100
X-MIMETrack: Serialize by Router on Marketing/PosAm Bratislava(Release 6.0.2CF2|July 23, 2003) at
 20.02.2004 10:59:16,
	Serialize complete at 20.02.2004 10:59:16
Content-Type: text/plain; charset="US-ASCII"
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_02_18 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0 tests=HAS_PACKAGE autolearn=no 
	version=2.60-bugs.debian.org_2004_02_18
X-Spam-Level: 

Package: libc6
Version: 2.3.2.ds1-11


Hi, 
it seems that locking / unlocking the same mutex by huge number of threads 
causes dead locks.
If I create N=1529 threads (probably system-dependent) that continually 
lock the same (non-recursive) mutex, everything is ok, program runs 
forever.
But if I increase the value by one (N=1530), program freezes after few 
seconds.
This may be a pthread_self() problem (if it's used in mutex 
implementation), because I found it returns non-unique id if N>1529.
(You may try to store pthread_self() value of the main thread in a global 
variable and assert( ! pthread_equal(main_thread_id, pthread_self()) ) in 
thread procedure.)

Here is an example code demonstrating this:


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

#define N_THREADS       1530

pthread_mutex_t    _mxIN;

void * thread_proc_r( void * param )
{
    int i = (int) param;
    while( 1 ) {                /// lock/unlock loop
        pthread_mutex_lock( &_mxIN );
        printf( "R%XR ", i );
        if( i % 10 == 0 ) printf( "\n" );
        pthread_mutex_unlock( &_mxIN );
    }
    return NULL;
}


int main()
{
    pthread_mutexattr_t m;
    pthread_mutexattr_settype( &m, PTHREAD_MUTEX_NORMAL );
    pthread_mutex_init( &_mxIN, &m );
    pthread_mutexattr_destroy( &m );

    pthread_mutex_lock( &_mxIN );
    pthread_t th;
    for( int i=0; i<N_THREADS; i++ )    // create threads
        pthread_create( &th, NULL, thread_proc_r, (void *) i );
    pthread_mutex_unlock( &_mxIN );

    while( 1 ) {                /// lock/unlock loop
        pthread_mutex_lock( &_mxIN );
        pthread_mutex_unlock( &_mxIN );
        /// we never get here
        printf( "Main unlock\n" );
    }
    return 0;
}




////////////////////////////////
System: Debian 3.0 r2

uname -a
Linux 62.168.66.120 2.4.25 #8 Thu Feb 19 16:01:07 CET 2004 i686 GNU/Linux

I noticed this behaviour in 2.4.24 kernel and libc6 v2.3.2.ds1-10, too

gcc -v
Thread model: posix
gcc version 3.3.2 (Debian)


Thanks,
Robert Strycek


---------------------------------------
Received: (at 233846-done) by bugs.debian.org; 12 Mar 2004 06:58:35 +0000
>From gotom@debian.or.jp Thu Mar 11 22:58:35 2004
Return-path: <gotom@debian.or.jp>
Received: from omega.webmasters.gr.jp (webmasters.gr.jp) [218.44.239.78] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1B1gct-0001hs-00; Thu, 11 Mar 2004 22:58:35 -0800
Received: from omega.webmasters.gr.jp (localhost [127.0.0.1])
	by webmasters.gr.jp (Postfix) with ESMTP
	id 6DD7DDEDF8; Fri, 12 Mar 2004 15:58:34 +0900 (JST)
Date: Fri, 12 Mar 2004 15:58:34 +0900
Message-ID: <81n06mzh45.wl@omega.webmasters.gr.jp>
From: GOTO Masanori <gotom@debian.or.jp>
To: Robert Strycek <strycek@posam.sk>, 233846-done@bugs.debian.org
Subject: Re: Bug#233846: pthread_mutex_lock/unlock problem
In-Reply-To: <81u11g5zzy.wl@omega.webmasters.gr.jp>
References: <OF286B2CA5.ABDB7E64-ONC1256E40.00324CD6-C1256E40.0036DCEB@smtpmta.posam.sk>
	<81u11g5zzy.wl@omega.webmasters.gr.jp>
User-Agent: Wanderlust/2.9.9 (Unchained Melody) SEMI/1.14.3 (Ushinoya)
 FLIM/1.14.3 (=?ISO-8859-4?Q?Unebigory=F2mae?=) APEL/10.3 Emacs/21.2
 (i386-debian-linux-gnu) MULE/5.0 (SAKAKI)
MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya")
Content-Type: text/plain; charset=US-ASCII
Delivered-To: 233846-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_08 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER 
	autolearn=no version=2.60-bugs.debian.org_2004_03_08
X-Spam-Level: 

At Tue, 24 Feb 2004 23:11:13 +0900,
GOTO Masanori wrote:
> You use kernel 2.4 + linuxthreads (not for 686).  I think this is
> problem.  Try to use kernel 2.6 + NPTL.  Debian does not provide
> "linuxthreads + 2.4 kernel + 686"-based libc6.  This means that you
> don't use even floating stack.  So if you want to fix this problem, I
> think you need to use kernel 2.6.
> 
> Please test your program which does not become deadlock on kernel 2.6.
> 
> I think this bug can be marked as fixed.

I closed this bug.

Regards,
-- gotom



Reply to: