From owner-freebsd-threads@FreeBSD.ORG Sun Nov 6 00:27:44 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01BB916A41F for ; Sun, 6 Nov 2005 00:27:44 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id A968343D46 for ; Sun, 6 Nov 2005 00:27:43 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR004.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IPI00LMFBY5VB70@VL-MO-MR004.ip.videotron.ca> for freebsd-threads@freebsd.org; Sat, 05 Nov 2005 19:27:42 -0500 (EST) Date: Sat, 05 Nov 2005 19:27:35 -0500 From: Nicolas Blais To: freebsd-threads@freebsd.org Message-id: <200511051927.40752.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart13399409.ValbMmn0Cg; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit User-Agent: KMail/1.8.3 Subject: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2005 00:27:44 -0000 --nextPart13399409.ValbMmn0Cg Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I've had FreeBSD and been C++'ing with it since version 3.1, and now I feel= =20 like I must jump into threading... I found a nice example with pthread (in C) here :=20 http://www.cs.ucsb.edu/~tyang/class/pthreads/index_sgi.html (see p_hello.c) It compiles and works fine. I'm trying to make the same program in C++. Is= =20 the syntax for pthreading the same as in C? I was wondering if someone can= =20 point me in the right direction. Also, is there anything I should be worried about when using pthread and C+= +?=20 (Some years ago, I heard that FreeBSD's pthread didn't like C++... could be= a=20 false rumour) Thanks, Nicolas. =2D-=20 =46reeBSD 7.0-CURRENT #0: Sat Nov 5 12:12:36 EST 2005 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart13399409.ValbMmn0Cg Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDbU38z38ton5LGeIRAowSAJ9U3Y0eXOpGwMlytJ40TFN7w1jARgCdHNmw Y8ILWSGd27M40gWVoJEcAFI= =Hyqi -----END PGP SIGNATURE----- --nextPart13399409.ValbMmn0Cg-- From owner-freebsd-threads@FreeBSD.ORG Sun Nov 6 04:07:51 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E13E816A420 for ; Sun, 6 Nov 2005 04:07:51 +0000 (GMT) (envelope-from oceanare@pacific.net.sg) Received: from smtpgate1.pacific.net.sg (smtpgate1.pacific.net.sg [203.120.90.27]) by mx1.FreeBSD.org (Postfix) with SMTP id 0644343D45 for ; Sun, 6 Nov 2005 04:07:50 +0000 (GMT) (envelope-from oceanare@pacific.net.sg) Received: (qmail 32146 invoked from network); 6 Nov 2005 04:07:48 -0000 Received: from maxwell6.pacific.net.sg (203.120.90.212) by smtpgate1.pacific.net.sg with SMTP; 6 Nov 2005 04:07:48 -0000 Received: from [192.168.0.107] ([210.24.246.23]) by maxwell6.pacific.net.sg with ESMTP id <20051106040747.IQHH16871.maxwell6.pacific.net.sg@[192.168.0.107]>; Sun, 6 Nov 2005 12:07:47 +0800 Message-ID: <436D8181.9090909@pacific.net.sg> Date: Sun, 06 Nov 2005 12:07:29 +0800 From: Erich Dollansky Organization: oceanare pte ltd User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051008) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nicolas Blais References: <200511051927.40752.nb_root@videotron.ca> In-Reply-To: <200511051927.40752.nb_root@videotron.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2005 04:07:52 -0000 Hi, Nicolas Blais wrote: > > It compiles and works fine. I'm trying to make the same program in C++. Is > the syntax for pthreading the same as in C? I was wondering if someone can > point me in the right direction. > the threading stuff stays the same. > Also, is there anything I should be worried about when using pthread and C++? > (Some years ago, I heard that FreeBSD's pthread didn't like C++... could be a > false rumour) You cannot use classes directly with threading functions. Your classes must be aware of threading. You need some mechanism to protect classes which are not threadsafe if more than one thread could access an object at te same moment of time. This is a general problem of threading which might causes problems. Do not forget that C++ uses additional data in objects which the programmer does not see. Erich From owner-freebsd-threads@FreeBSD.ORG Mon Nov 7 00:18:02 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7CB8816A41F for ; Mon, 7 Nov 2005 00:18:02 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2242F43D46 for ; Mon, 7 Nov 2005 00:18:02 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR002.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IPK00J2A660GAK0@VL-MO-MR002.ip.videotron.ca> for freebsd-threads@freebsd.org; Sun, 06 Nov 2005 19:18:01 -0500 (EST) Date: Sun, 06 Nov 2005 19:17:52 -0500 From: Nicolas Blais In-reply-to: <436D8181.9090909@pacific.net.sg> To: Erich Dollansky Message-id: <200511061918.00437.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart1210774.aLU6Faaqad; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit References: <200511051927.40752.nb_root@videotron.ca> <436D8181.9090909@pacific.net.sg> User-Agent: KMail/1.8.3 Cc: freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2005 00:18:02 -0000 --nextPart1210774.aLU6Faaqad Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On November 5, 2005 11:07 pm, Erich Dollansky wrote: > Hi, > > Nicolas Blais wrote: > > It compiles and works fine. I'm trying to make the same program in C++.= =20 > > Is the syntax for pthreading the same as in C? I was wondering if someo= ne > > can point me in the right direction. > > the threading stuff stays the same. > > > Also, is there anything I should be worried about when using pthread and > > C++? (Some years ago, I heard that FreeBSD's pthread didn't like C++... > > could be a false rumour) > > You cannot use classes directly with threading functions. Your classes > must be aware of threading. You need some mechanism to protect classes > which are not threadsafe if more than one thread could access an object > at te same moment of time. > > This is a general problem of threading which might causes problems. > > Do not forget that C++ uses additional data in objects which the > programmer does not see. > > Erich //warn long message Well, at least it's feasible. =20 Actually, so far I've converted an single threaded application which was=20 helped by pthreading so I'm on the right track. (Instead of performing a=20 calculation 5+E07 times, I've split it in 'n' threads that does part of the= =20 calculation. Threading gives a small performance boost on my 64/3800 but I'= m=20 sure it would be even more on a dual-core or multiprocessor system). Now my current problem is that it uses a class and like you mentionned, and= =20 the threads access the same data within the class. This is the desired=20 operation for most of my variables except one which I want to be thread=20 independant. =46or example: Let's say I have 4 threads performing 1000 calculations. Eac= h=20 thread adds +1 to the global counter so that at the end of the program I ha= ve=20 4000 in that counter. I cannot yet have an individual counter per thread so= =20 that at the end of the program, each thread's counter =3D 1000. I've tried using an array like : array[thread_id] which works fine for smal= l=20 numbers, but as soon as I get into large numbers (way into 'double'), I=20 occasionnaly get corrupt numbers. The data doesn't get corrupted below a=20 counter of around 1+E6. I'm guessing the threads are adding in each other's= =20 "individual" counters. =46rom what I found, pthread_key_create() could be what I need, but I haven= 't=20 found one C++ implementation that could get me to understand it. I did find= =20 many C example, but they either heavily depend on malloc(), casts and such = or=20 they don't compile at all (some are 5 years old Solaris stuff). Can anyone show me the correct path? Any help is truly appreciated. =2D-=20 =46reeBSD 7.0-CURRENT #0: Sat Nov 5 12:12:36 EST 2005 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart1210774.aLU6Faaqad Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDbp04z38ton5LGeIRAuouAJwPewuWEIpX0QDV/iGjn96t6GEzAACeNKcR 2OK3cAVCryik/bLvv2yuexc= =I/RQ -----END PGP SIGNATURE----- --nextPart1210774.aLU6Faaqad-- From owner-freebsd-threads@FreeBSD.ORG Mon Nov 7 07:12:01 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E0CD16A41F for ; Mon, 7 Nov 2005 07:12:01 +0000 (GMT) (envelope-from nkoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 952E743D45 for ; Mon, 7 Nov 2005 07:11:58 +0000 (GMT) (envelope-from nkoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id 37964A2867; Mon, 7 Nov 2005 08:11:57 +0100 (CET) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03533-05; Mon, 7 Nov 2005 08:11:53 +0100 (CET) Received: from firewall.demig (p508392D1.dip0.t-ipconnect.de [80.131.146.209]) by server.absolute-media.de (Postfix) with ESMTP id 2719BA2C1D; Mon, 7 Nov 2005 08:11:53 +0100 (CET) Received: from entw-pr (entw-pr.w2kdemig [192.168.1.40]) by firewall.demig (8.13.5/8.13.4) with ESMTP id jA77AUjj015243; Mon, 7 Nov 2005 08:10:30 +0100 (CET) (envelope-from nkoch@demig.de) X-Originating-IP: [192.168.1.72] From: "Norbert Koch" To: "Nicolas Blais" , "Erich Dollansky" In-Reply-To: <200511061918.00437.nb_root@videotron.ca> Date: Mon, 07 Nov 2005 08:10:30 +0100 Message-ID: <20051107.lED.26049900@entw-pr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-Disposition: inline X-Mailer: AngleMail for eGroupWare (http://www.egroupware.org) v 1.0.0.009 X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Cc: freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2005 07:12:01 -0000 Hi. If you want to have classes with threads, I suggest you try the port devel/commoncpp. It is a portable c++ library for multi-threading. From my experience it works fine. Norbert Nicolas Blais (nb_root@videotron.ca) schrieb: > > On November 5, 2005 11:07 pm, Erich Dollansky wrote: > > Hi, > > > > Nicolas Blais wrote: > > > It compiles and works fine. I'm trying to make the same program in C++. > > > Is the syntax for pthreading the same as in C? I was wondering if someone > > > can point me in the right direction. > > > > the threading stuff stays the same. > > > > > Also, is there anything I should be worried about when using pthread and > > > C++? (Some years ago, I heard that FreeBSD's pthread didn't like C++... > > > could be a false rumour) > > > > You cannot use classes directly with threading functions. Your classes > > must be aware of threading. You need some mechanism to protect classes > > which are not threadsafe if more than one thread could access an object > > at te same moment of time. > > > > This is a general problem of threading which might causes problems. > > > > Do not forget that C++ uses additional data in objects which the > > programmer does not see. > > > > Erich > > //warn long message > > Well, at least it's feasible. > > Actually, so far I've converted an single threaded application which was > helped by pthreading so I'm on the right track. (Instead of performing a > calculation 5+E07 times, I've split it in 'n' threads that does part of the > calculation. Threading gives a small performance boost on my 64/3800 but I'm > sure it would be even more on a dual-core or multiprocessor system). > > Now my current problem is that it uses a class and like you mentionned, and > the threads access the same data within the class. This is the desired > operation for most of my variables except one which I want to be thread > independant. > > For example: Let's say I have 4 threads performing 1000 calculations. Each > thread adds +1 to the global counter so that at the end of the program I have > 4000 in that counter. I cannot yet have an individual counter per thread so > that at the end of the program, each thread's counter = 1000. > > I've tried using an array like : array[thread_id] which works fine for small > numbers, but as soon as I get into large numbers (way into 'double'), I > occasionnaly get corrupt numbers. The data doesn't get corrupted below a > counter of around 1+E6. I'm guessing the threads are adding in each other's > "individual" counters. > > From what I found, pthread_key_create() could be what I need, but I haven't > found one C++ implementation that could get me to understand it. I did find > many C example, but they either heavily depend on malloc(), casts and such or > they don't compile at all (some are 5 years old Solaris stuff). > > Can anyone show me the correct path? > > Any help is truly appreciated. > -- > FreeBSD 7.0-CURRENT #0: Sat Nov 5 12:12:36 EST 2005 > root@clk01a:/usr/obj/usr/src/sys/CLK01A > PGP? : http://www.clkroot.net/security/nb_root.asc > From owner-freebsd-threads@FreeBSD.ORG Mon Nov 7 11:02:18 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF18616A41F for ; Mon, 7 Nov 2005 11:02:18 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F0F143D46 for ; Mon, 7 Nov 2005 11:02:18 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jA7B2Ipj050036 for ; Mon, 7 Nov 2005 11:02:18 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jA7B2Hpp050029 for freebsd-threads@freebsd.org; Mon, 7 Nov 2005 11:02:17 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 7 Nov 2005 11:02:17 GMT Message-Id: <200511071102.jA7B2Hpp050029@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to you X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2005 11:02:19 -0000 Current FreeBSD problem reports Critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2005/01/26] threads/76690threads fork hang in child for (-lc_r & -lthr) 1 problem total. Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/07/18] kern/20016 threads pthreads: Cannot set scheduling timer/Can o [2000/08/26] kern/20861 threads libc_r does not honor socket timeouts o [2001/01/20] threads/24472threads libc_r does not honor SO_SNDTIMEO/SO_RCVT o [2001/01/25] threads/24632threads libc_r delicate deviation from libc in ha o [2001/01/25] kern/24641 threads pthread_rwlock_rdlock can deadlock o [2001/11/26] bin/32295 threads pthread dont dequeue signals o [2002/02/01] threads/34536threads accept() blocks other threads o [2002/05/25] kern/38549 threads the procces compiled whith pthread stoppe o [2002/06/27] threads/39922threads [threads] [patch] Threaded applications e o [2002/08/04] kern/41331 threads Pthread library open sets O_NONBLOCK flag o [2003/03/02] threads/48856threads Setting SIGCHLD to SIG_IGN still leaves z o [2003/03/10] threads/49087threads Signals lost in programs linked with libc s [2004/03/15] kern/64313 threads FreeBSD (OpenBSD) pthread implicit set/un o [2004/08/26] threads/70975threads unexpected and unreliable behaviour when o [2004/10/05] threads/72353threads Assertion fails in /usr/src/lib/libpthrea o [2004/10/07] threads/72429threads threads blocked in stdio (fgets, etc) are o [2004/10/21] threads/72953threads fork() unblocks blocked signals w/o PTHRE o [2004/12/19] threads/75273threads FBSD 5.3 libpthread (KSE) bug o [2004/12/21] threads/75374threads pthread_kill() ignores SA_SIGINFO flag o [2005/01/26] threads/76694threads fork cause hang in dup()/close() function o [2005/03/10] threads/78660threads Java hangs unkillably in STOP state after o [2005/04/08] threads/79683threads svctcp_create() fails if multiple threads o [2005/04/28] threads/80435threads panic on high loads o [2005/05/19] threads/81258threads Thread specific data is sometimes assigne o [2005/08/02] threads/84483threads problems with devel/nspr and -lc_r on 4.x s [2005/08/10] threads/84778threads libpthread busy loop/hang with Java when o [2005/08/20] threads/85160threads [libthr] [patch] libobjc + libpthread/lib 27 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/05/26] kern/18824 threads gethostbyname is not thread safe o [2000/06/13] kern/19247 threads uthread_sigaction.c does not do anything o [2000/10/21] kern/22190 threads A threaded read(2) from a socketpair(2) f o [2001/09/09] threads/30464threads pthread mutex attributes -- pshared o [2002/05/02] threads/37676threads libc_r: msgsnd(), msgrcv(), pread(), pwri s [2002/07/16] threads/40671threads pthread_cancel doesn't remove thread from o [2004/07/13] threads/69020threads pthreads library leaks _gc_mutex o [2004/09/21] threads/71966threads Mlnet Core Dumped : Fatal error '_pq_inse o [2004/11/21] threads/74180threads KSE problem. Applications those riched ma o [2005/04/13] threads/79887threads [patch] freopen() isn't thread-safe o [2005/05/13] threads/80992threads abort() sometimes not caught by gdb depen o [2005/05/26] threads/81534threads [libc_r] [patch] libc_r close() will fail 12 problems total. From owner-freebsd-threads@FreeBSD.ORG Mon Nov 7 11:57:44 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3B99216A41F for ; Mon, 7 Nov 2005 11:57:44 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from porthos.st-andrews.ac.uk (porthos.st-and.ac.uk [138.251.66.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DECC43D49 for ; Mon, 7 Nov 2005 11:57:42 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from kate (res05-ned6.res.st-and.ac.uk [138.251.224.28]) by porthos.st-andrews.ac.uk (8.12.9/8.12.9) with SMTP id jA7BvIKa008031; Mon, 7 Nov 2005 11:57:22 GMT From: "Niall Douglas" To: freebsd-threads@freebsd.org Date: Mon, 07 Nov 2005 11:57:13 -0000 MIME-Version: 1.0 Message-ID: <436F4119.5345.92723A0@localhost> Priority: normal In-reply-to: <20051107.lED.26049900@entw-pr> References: <200511061918.00437.nb_root@videotron.ca> X-mailer: Pegasus Mail for Windows (4.21c) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-StAndrews-MailScanner-Information: Please contact the ISP for more information X-StAndrews-MailScanner: No virus detected X-StAndrews-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 5, autolearn=not spam) X-StAndrews-MailScanner-From: s_sourceforge@nedprod.com Cc: Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2005 11:57:44 -0000 On 7 Nov 2005 at 8:10, Norbert Koch wrote: > Hi. > If you want to have classes with threads, I suggest > you try the port devel/commoncpp. It is a portable > c++ library for multi-threading. From my experience > it works fine. You could also try a free GUI toolkit. My own, TnFOX (http://www.nedprod.com/TnFOX) can be built so that all the GUI stuff is left out and you have just the system interface stuff. FXThreadLocalStorage provides TLS, FXMutex is a highly optimised hand written recursive mutex and FXThread provides a high level portable thread implementation with cancellation facilities. The documentation is at http://tnfox.sourceforge.net/TnFOX/html/ It's all regularly tested on FreeBSD. Cheers, Niall From owner-freebsd-threads@FreeBSD.ORG Mon Nov 7 21:38:20 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3617E16A423 for ; Mon, 7 Nov 2005 21:38:20 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id F1CE343D68 for ; Mon, 7 Nov 2005 21:38:13 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR001.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IPL000FZTFOI050@VL-MO-MR001.ip.videotron.ca> for freebsd-threads@freebsd.org; Mon, 07 Nov 2005 16:38:13 -0500 (EST) Date: Mon, 07 Nov 2005 16:38:02 -0500 From: Nicolas Blais In-reply-to: <20051107.lED.26049900@entw-pr> To: Norbert Koch Message-id: <200511071638.12602.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart2535190.jxpq6lZrIZ; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit References: <20051107.lED.26049900@entw-pr> User-Agent: KMail/1.8.3 Cc: freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2005 21:38:20 -0000 --nextPart2535190.jxpq6lZrIZ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On November 7, 2005 02:10 am, Norbert Koch wrote: > Hi. > If you want to have classes with threads, I suggest > you try the port devel/commoncpp. It is a portable > c++ library for multi-threading. From my experience > it works fine. > Norbert > Thanks for your reply! Performance wise, would you think commoncpp is better with threads than=20 directly pthread? Nicolas. =2D-=20 =46reeBSD 7.0-CURRENT #0: Sat Nov 5 12:12:36 EST 2005 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart2535190.jxpq6lZrIZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDb8lEz38ton5LGeIRAtOOAKCmUhfI0Plga6j+1CNuCCeg/VVQPACfaAcX EfpOuuMzq8JwoVb8/eJWASo= =J4KF -----END PGP SIGNATURE----- --nextPart2535190.jxpq6lZrIZ-- From owner-freebsd-threads@FreeBSD.ORG Tue Nov 8 07:07:02 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C2F4816A41F for ; Tue, 8 Nov 2005 07:07:02 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BC5F43D46 for ; Tue, 8 Nov 2005 07:07:01 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id 01801A40D3; Tue, 8 Nov 2005 08:07:00 +0100 (CET) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09507-01; Tue, 8 Nov 2005 08:06:54 +0100 (CET) Received: from firewall.demig (p50839BB8.dip0.t-ipconnect.de [80.131.155.184]) by server.absolute-media.de (Postfix) with ESMTP id 179BC8A1C1; Tue, 8 Nov 2005 08:06:54 +0100 (CET) Received: from ws-ew-3 (ws-ew-3.w2kdemig [192.168.1.72]) by firewall.demig (8.13.5/8.13.4) with SMTP id jA876chY043817; Tue, 8 Nov 2005 08:06:38 +0100 (CET) (envelope-from NKoch@demig.de) From: "Norbert Koch" To: "Nicolas Blais" Date: Tue, 8 Nov 2005 08:06:46 +0100 Message-ID: <000701c5e432$fb600980$4801a8c0@ws-ew-3.demig.intra> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-reply-to: <200511071638.12602.nb_root@videotron.ca> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 Importance: Normal X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Cc: freebsd-threads@freebsd.org Subject: RE: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2005 07:07:02 -0000 > -----Original Message----- > From: Nicolas Blais [mailto:nb_root@videotron.ca] > Sent: Monday, November 07, 2005 10:38 PM > To: Norbert Koch > Cc: freebsd-threads@freebsd.org > Subject: Re: c++ with pthread? > > > On November 7, 2005 02:10 am, Norbert Koch wrote: > > Hi. > > If you want to have classes with threads, I suggest > > you try the port devel/commoncpp. It is a portable > > c++ library for multi-threading. From my experience > > it works fine. > > Norbert > > > > Thanks for your reply! > > Performance wise, would you think commoncpp is better with threads than > directly pthread? > > Nicolas. Commoncpp tries to be platform-independent. So, no. What performance are you talking about? Thread creation may be slower, but context changes are always handled by pthread. So there would be no difference. Mutexes and conditionals will be slower too. I never ran any benchmarks. From owner-freebsd-threads@FreeBSD.ORG Tue Nov 8 09:47:30 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BC8D16A41F for ; Tue, 8 Nov 2005 09:47:30 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from athos.st-andrews.ac.uk (athos.st-and.ac.uk [138.251.61.174]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9295243D45 for ; Tue, 8 Nov 2005 09:47:28 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from kate (res05-ned6.res.st-and.ac.uk [138.251.224.28]) by athos.st-andrews.ac.uk (8.12.9/8.12.9) with SMTP id jA89kueo016720; Tue, 8 Nov 2005 09:46:56 GMT From: "Niall Douglas" To: freebsd-threads@freebsd.org Date: Tue, 08 Nov 2005 09:46:50 -0000 MIME-Version: 1.0 Message-ID: <4370740A.32492.2B723FE@localhost> Priority: normal In-reply-to: <000701c5e432$fb600980$4801a8c0@ws-ew-3.demig.intra> References: <200511071638.12602.nb_root@videotron.ca> X-mailer: Pegasus Mail for Windows (4.21c) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-StAndrews-MailScanner-Information: Please contact the ISP for more information X-StAndrews-MailScanner: No virus detected X-StAndrews-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, required 5, autolearn=not spam, BAYES_00 -4.90) X-StAndrews-MailScanner-From: s_sourceforge@nedprod.com Cc: Subject: RE: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2005 09:47:30 -0000 On 8 Nov 2005 at 8:06, Norbert Koch wrote: > > Thanks for your reply! > > > > Performance wise, would you think commoncpp is better with threads than > > directly pthread? > > > > Nicolas. > > Commoncpp tries to be platform-independent. So, no. > What performance are you talking about? Thread creation > may be slower, but context changes are always handled by > pthread. So there would be no difference. > Mutexes and conditionals will be slower too. > I never ran any benchmarks. The implementation of mutexes is the single biggest determinant of heavily multithreaded code. FreeBSD has a very simple memory allocator which always serialises to one thread, resulting in VERY poor performance when you have three or more threads running at once. TnFOX has its own memory allocator (ptmalloc2) as well as its own mutex implementation. I haven't found any system (win32, win64, linux or freebsd) whose native facilities come anywhere close to TnFOX's threading performance. In other words, choosing a good optimised threading library makes ALL the difference to performance. I once again strongly suggest that the FreeBSD memory allocator in libc is replaced with ptmalloc2 (http://www.nedprod.com/programs/Win32/ptmalloc2/ - its MIT licence). Doing this gives a several fold speed increase even in single threaded C++ apps due to the fastbins. Cheers, Niall From owner-freebsd-threads@FreeBSD.ORG Tue Nov 8 10:56:29 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 45FF416A458 for ; Tue, 8 Nov 2005 10:56:29 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD55543D48 for ; Tue, 8 Nov 2005 10:56:28 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR001.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IPM0048RUBCIIA0@VL-MO-MR001.ip.videotron.ca> for freebsd-threads@freebsd.org; Tue, 08 Nov 2005 05:54:48 -0500 (EST) Date: Tue, 08 Nov 2005 05:54:43 -0500 From: Nicolas Blais In-reply-to: <000701c5e432$fb600980$4801a8c0@ws-ew-3.demig.intra> To: freebsd-threads@freebsd.org Message-id: <200511080554.48373.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart5418983.vW4Y3AATdm; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit References: <000701c5e432$fb600980$4801a8c0@ws-ew-3.demig.intra> User-Agent: KMail/1.8.3 Cc: Norbert Koch Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2005 10:56:29 -0000 --nextPart5418983.vW4Y3AATdm Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > Commoncpp tries to be platform-independent. So, no. > What performance are you talking about? Thread creation > may be slower, but context changes are always handled by > pthread. So there would be no difference. > Mutexes and conditionals will be slower too. > I never ran any benchmarks. Actually, I've run into a decision forcing event with commoncpp. It segfaul= ts=20 one of it's own very simple test code (thread2.cpp) : http://www.gnu.org/software/commoncpp/docs/refman/html/thread2_8cpp-example= =2Ehtml Either it's me, FreeBSD or the actual librairie that cause the segfault. I'= ve=20 even 'sent-pr' to update the port to the last version and it causes the sam= e=20 segfault. gdb gives: Starting program: /home/nicblais/test/cc/a.out (no debugging symbols found)...(no debugging symbols found)...(no debugging= =20 symbols found)...(no debugging symbols found)...(no debugging symbols=20 found)...(no debugging symbols found)...(no debugging symbols=20 found)...warning: Unable to get location for thread creation breakpoint:=20 generic error [New LWP 100180] (no debugging symbols found)...(no debugging symbols found)...(no debugging= =20 symbols found)...starting father thread starting child thread child start father end child end [New Thread 0x8057600 (LWP 100180)] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x8057600 (LWP 100180)] 0x280d4c95 in ost::Thread::close () from /usr/local/lib/libccgnu2-1.3.so.1 from thread2.cpp compile like so: gcc -I/usr/local/include/cc++2 -D_THREAD_SAFE -D_GNU_SOURCE=20 =2DI/usr/local/include -L/usr/local/lib -lccext2 -lccgnu2 -L/usr/local/lib= =20 =2Dlxml2 -lz -L/usr/local/lib -liconv -lm -lz -pthread thread2.cpp Since the actual fault is in libccgnu2, I've submitted a bug report on=20 sourceforge. Sadly enough, this situation has cause me to stay with pthread so far. About ptmalloc2, is the reason it wasn't implemented a compatibility issue= ?=20 Licensing maybe? Technical? Nicolas. =2D-=20 =46reeBSD 7.0-CURRENT #0: Sat Nov 5 12:12:36 EST 2005 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? : http://www.clkroot.net/security/nb_root.asc --nextPart5418983.vW4Y3AATdm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDcIP4z38ton5LGeIRAmpcAKCCS26KPGmPxRKrLJuknpxRPYdCgACgl6ou FESQGSg6PrWMmXbp2F1+i8w= =bcZs -----END PGP SIGNATURE----- --nextPart5418983.vW4Y3AATdm-- From owner-freebsd-threads@FreeBSD.ORG Tue Nov 8 13:57:19 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E89E616A41F for ; Tue, 8 Nov 2005 13:57:19 +0000 (GMT) (envelope-from delphij@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AE8743D49 for ; Tue, 8 Nov 2005 13:57:19 +0000 (GMT) (envelope-from delphij@gmail.com) Received: by wproxy.gmail.com with SMTP id i32so529376wra for ; Tue, 08 Nov 2005 05:57:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=cQPC8xdMXczNQ9A31SqXZtt2MA+VF4/5CZweJt5btGf/Sxm4vokVStx/l5chKmCzcbPmAbLo23vHJXZGGH1vd9Zu8ELDP77pKopBJDhaxlgO9X1ME5mw7jFbNPTllJqIDyM5M9QG62H03w6KwRTOua5ixJ+koLzyDQolbl+UBPY= Received: by 10.65.235.11 with SMTP id m11mr6563404qbr; Tue, 08 Nov 2005 05:50:20 -0800 (PST) Received: by 10.65.191.18 with HTTP; Tue, 8 Nov 2005 05:50:20 -0800 (PST) Message-ID: Date: Tue, 8 Nov 2005 21:50:20 +0800 From: Xin LI To: Nicolas Blais In-Reply-To: <200511080554.48373.nb_root@videotron.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Content-Disposition: inline References: <000701c5e432$fb600980$4801a8c0@ws-ew-3.demig.intra> <200511080554.48373.nb_root@videotron.ca> Cc: Norbert Koch , freebsd-threads@freebsd.org Subject: Re: c++ with pthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2005 13:57:20 -0000 T24gMTEvOC8wNSwgTmljb2xhcyBCbGFpcyA8bmJfcm9vdEB2aWRlb3Ryb24uY2E+IHdyb3RlOgpb Li4uXQo+IEVpdGhlciBpdCdzIG1lLCBGcmVlQlNEIG9yIHRoZSBhY3R1YWwgbGlicmFpcmllIHRo YXQgY2F1c2UgdGhlIHNlZ2ZhdWx0LiBJJ3ZlCj4gZXZlbiAnc2VudC1wcicgdG8gdXBkYXRlIHRo ZSBwb3J0IHRvIHRoZSBsYXN0IHZlcnNpb24gYW5kIGl0IGNhdXNlcyB0aGUgc2FtZQo+IHNlZ2Zh dWx0LgoKSGF2ZSB5b3UgdHJpZWQgcHRtYWxsb2MgZnJvbSBwb3J0cyBjb2xsZWN0aW9uPyAgSSB0 aGluayB0aGVyZSBtaWdodCBiZQpzb21lIHRlY2huaWNhbCAoZGVidWdnaW5nIGlzc3VlIElJUkMp IGFuZC9vciBzb21lIGxpY2Vuc2luZyBpc3N1ZSwgYnV0CnJlbWVtYmVyIHRoaW5ncyBjYW4gYmUg cmVzb2x2ZWQgaWYgd2Ugd29yayBvbiBpdCA6LSkKCkNoZWVycywK From owner-freebsd-threads@FreeBSD.ORG Wed Nov 9 15:48:04 2005 Return-Path: X-Original-To: freebsd-threads@FreeBSD.org Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5359516A41F for ; Wed, 9 Nov 2005 15:48:04 +0000 (GMT) (envelope-from bland@FreeBSD.org) Received: from mvs5.plala.or.jp (c158133.vh.plala.or.jp [210.150.158.133]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8FDF143D45 for ; Wed, 9 Nov 2005 15:48:03 +0000 (GMT) (envelope-from bland@FreeBSD.org) Received: from hub.bbnest.net ([220.220.221.240]) by mvs5.plala.or.jp with ESMTP id <20051109154801.DSFI3620.mvs5.plala.or.jp@hub.bbnest.net> for ; Thu, 10 Nov 2005 00:48:01 +0900 Received: from [10.0.0.2] (nest.bbnest.net [10.0.0.2]) by hub.bbnest.net (8.13.4/8.13.4) with ESMTP id jA9Fm1NO004634 for ; Thu, 10 Nov 2005 00:48:01 +0900 (JST) (envelope-from bland@FreeBSD.org) Message-ID: <43721989.3030802@FreeBSD.org> Date: Thu, 10 Nov 2005 00:45:13 +0900 From: Alexander Nedotsukov User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20050930 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-threads@FreeBSD.org Content-Type: multipart/mixed; boundary="------------020901020205070102060602" Cc: Subject: bogus pthread_cond_wait stub? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2005 15:48:04 -0000 This is a multi-part message in MIME format. --------------020901020205070102060602 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Guys, Doesn't patch attached look reasonable for you? From my deletant point of view :-) this seems to be the culprit of mysterious crashes in multithreaded plugins loaded by singlethreaded program. Thanks, Alexander. --------------020901020205070102060602 Content-Type: text/x-patch; name="_pthread_stubs.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="_pthread_stubs.c.patch" Index: _pthread_stubs.c =================================================================== RCS file: /home/ncvs/src/lib/libc/gen/_pthread_stubs.c,v retrieving revision 1.11 diff -u -r1.11 _pthread_stubs.c --- _pthread_stubs.c 29 Jul 2004 18:07:08 -0000 1.11 +++ _pthread_stubs.c 9 Nov 2005 15:31:17 -0000 @@ -176,7 +176,7 @@ STUB_FUNC1(pthread_cond_destroy, PJT_COND_DESTROY, int, void *) STUB_FUNC2(pthread_cond_init, PJT_COND_INIT, int, void *, void *) STUB_FUNC1(pthread_cond_signal, PJT_COND_SIGNAL, int, void *) -STUB_FUNC1(pthread_cond_wait, PJT_COND_WAIT, int, void *) +STUB_FUNC2(pthread_cond_wait, PJT_COND_WAIT, int, void *, void *) STUB_FUNC1(pthread_getspecific, PJT_GETSPECIFIC, void *, pthread_key_t) STUB_FUNC2(pthread_key_create, PJT_KEY_CREATE, int, void *, void *) STUB_FUNC1(pthread_key_delete, PJT_KEY_DELETE, int, pthread_key_t) --------------020901020205070102060602-- From owner-freebsd-threads@FreeBSD.ORG Fri Nov 11 03:31:41 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B39C16A41F for ; Fri, 11 Nov 2005 03:31:41 +0000 (GMT) (envelope-from gabriel.becedillas@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id D2D9143D49 for ; Fri, 11 Nov 2005 03:31:40 +0000 (GMT) (envelope-from gabriel.becedillas@gmail.com) Received: by wproxy.gmail.com with SMTP id i12so105115wra for ; Thu, 10 Nov 2005 19:31:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=sEgdHqYVONI5MvB74Ythbhmwu3rcqOMuWBMjDFgdy5YC2GBkjWyhh4leNQFppPzTN9PEPsKsiaqKhZolZUB+BDfKfPQB7LdwsWirKz/6LehpJvXUqwi+m2TGUEAjnWa69ZCzh+yBLsun0TatQBtHuVzxSg2VEoosBn4xU0KD1UM= Received: by 10.54.86.19 with SMTP id j19mr1229940wrb; Thu, 10 Nov 2005 19:31:40 -0800 (PST) Received: from ?192.168.1.2? ( [201.235.219.144]) by mx.gmail.com with ESMTP id 6sm822917wrl.2005.11.10.19.31.38; Thu, 10 Nov 2005 19:31:39 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v623) Content-Transfer-Encoding: 7bit Message-Id: <1139bd2a4492e98c3fcf367d5dc1ba00@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: freebsd-threads@freebsd.org From: Gabriel Becedillas Date: Fri, 11 Nov 2005 00:37:19 -0300 X-Mailer: Apple Mail (2.623) Subject: pthreads and segmentation fault X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2005 03:31:41 -0000 Hi, I'm getting a segmentation fault on FreeBSD 5.4 using pthreads. I was googling around and found that there are a lot of people hitting the same bug, but didn't found a solution to it yet. The active threads on my application are this ones: (gdb) info threads * 8 LWP 100052 0x2824231b in pthread_testcancel () from /usr/lib/libpthread.so.1 7 Thread 7 (sleeping) 0x2823a207 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1 6 Thread 6 (LWP 100106) 0x282422fb in pthread_testcancel () from /usr/lib/libpthread.so.1 5 Thread 5 (sleeping) 0x2823a207 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1 4 Thread 4 (sleeping) 0x2823a207 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1 3 Thread 3 (runnable) 0x2836af7b in select () from /lib/libc.so.5 2 Thread 2 (sleeping) 0x2823a207 in pthread_mutexattr_init () from /usr/lib/libpthread.so.1 1 Thread 1 (runnable) 0x283d49ff in flockfile () from /lib/libc.so.5 My application runs ok on other platforms (Linux and Mac OS X) and since there are a lot of people hitting the same bug ( always pthread_testcancel() & pthread_mutexattr_init() around ) I think that there must be something wrong in FreeBSD pthreads implementation. I really need to find a solution to my problem as soon as possible. Does anyone have a solution to this ? I've talked to a guy that is hitting the same problem and he told me that this is not fixed on FreeBSD 6.0. Thanks a lot. From owner-freebsd-threads@FreeBSD.ORG Fri Nov 11 04:29:31 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 78AAD16A420 for ; Fri, 11 Nov 2005 04:29:31 +0000 (GMT) (envelope-from freebsd@spatula.net) Received: from turing.morons.org (morons.org [64.147.161.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B2AC43D5F for ; Fri, 11 Nov 2005 04:29:30 +0000 (GMT) (envelope-from freebsd@spatula.net) Received: from localhost (localhost.morons.org [127.0.0.1]) by turing.morons.org (Postfix) with ESMTP id C619F17046; Thu, 10 Nov 2005 20:29:34 -0800 (PST) Received: from turing.morons.org ([127.0.0.1]) by localhost (turing.morons.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12069-07; Thu, 10 Nov 2005 20:29:25 -0800 (PST) Received: by turing.morons.org (Postfix, from userid 1001) id 9777B17044; Thu, 10 Nov 2005 20:29:25 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by turing.morons.org (Postfix) with ESMTP id 945C117036; Thu, 10 Nov 2005 20:29:25 -0800 (PST) Date: Thu, 10 Nov 2005 20:29:25 -0800 (PST) From: Nick Johnson X-X-Sender: spatula@turing.morons.org To: Gabriel Becedillas In-Reply-To: <1139bd2a4492e98c3fcf367d5dc1ba00@gmail.com> Message-ID: <20051110202052.O44305@turing.morons.org> References: <1139bd2a4492e98c3fcf367d5dc1ba00@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: amavisd-new at morons.org Cc: freebsd-threads@freebsd.org Subject: Re: pthreads and segmentation fault X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2005 04:29:31 -0000 What happens if you use libmap to point pthreads at libc_r using /etc/libmap.conf? You'll need something like this: [/usr/local/jdk1.4.2/] libpthread.so.1 libc_r.so.5 libpthread.so libc_r.so I've seen basically the same behaviour with Java. See: http://www.freebsd.org/cgi/query-pr.cgi?pr=threads/84778 Things that are utterly broken with libpthread (kse) often will work just fine with libc_r. But of course there are no bugs in libpthread and KSE works flawlessly. On Fri, 11 Nov 2005, Gabriel Becedillas wrote: > Hi, > I'm getting a segmentation fault on FreeBSD 5.4 using pthreads. I was > googling around and found that there are a lot of people hitting the same > bug, but didn't found a solution to it yet. > The active threads on my application are this ones: > > (gdb) info threads > * 8 LWP 100052 0x2824231b in pthread_testcancel () > from /usr/lib/libpthread.so.1 > 7 Thread 7 (sleeping) 0x2823a207 in pthread_mutexattr_init () > from /usr/lib/libpthread.so.1 > 6 Thread 6 (LWP 100106) 0x282422fb in pthread_testcancel () > from /usr/lib/libpthread.so.1 > 5 Thread 5 (sleeping) 0x2823a207 in pthread_mutexattr_init () > from /usr/lib/libpthread.so.1 > 4 Thread 4 (sleeping) 0x2823a207 in pthread_mutexattr_init () > from /usr/lib/libpthread.so.1 > 3 Thread 3 (runnable) 0x2836af7b in select () from /lib/libc.so.5 > 2 Thread 2 (sleeping) 0x2823a207 in pthread_mutexattr_init () > from /usr/lib/libpthread.so.1 > 1 Thread 1 (runnable) 0x283d49ff in flockfile () from /lib/libc.so.5 From owner-freebsd-threads@FreeBSD.ORG Fri Nov 11 08:43:00 2005 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1949C16A420; Fri, 11 Nov 2005 08:43:00 +0000 (GMT) (envelope-from davidxu@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD94343D45; Fri, 11 Nov 2005 08:42:59 +0000 (GMT) (envelope-from davidxu@FreeBSD.org) Received: from freefall.freebsd.org (davidxu@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jAB8gxJ2003672; Fri, 11 Nov 2005 08:42:59 GMT (envelope-from davidxu@freefall.freebsd.org) Received: (from davidxu@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jAB8gxjK003668; Fri, 11 Nov 2005 08:42:59 GMT (envelope-from davidxu) Date: Fri, 11 Nov 2005 08:42:59 GMT From: David Xu Message-Id: <200511110842.jAB8gxjK003668@freefall.freebsd.org> To: hook@aktrad.ru, davidxu@FreeBSD.org, freebsd-threads@FreeBSD.org Cc: Subject: Re: kern/18824: gethostbyname is not thread safe X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2005 08:43:00 -0000 Synopsis: gethostbyname is not thread safe State-Changed-From-To: open->closed State-Changed-By: davidxu State-Changed-When: Fri Nov 11 08:40:49 GMT 2005 State-Changed-Why: I think it was fixed in 6.0, it is thread safe: > These functions use a thread-specific data storage; if the data is needed > for future use, it should be copied before any subsequent calls overwrite > it. http://www.freebsd.org/cgi/query-pr.cgi?pr=18824 From owner-freebsd-threads@FreeBSD.ORG Fri Nov 11 20:25:24 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E92E916A421 for ; Fri, 11 Nov 2005 20:25:24 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 46C4A43D4C for ; Fri, 11 Nov 2005 20:25:24 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.5/8.13.5/NETPLEX) with ESMTP id jABKPNYY025233; Fri, 11 Nov 2005 15:25:23 -0500 (EST) Date: Fri, 11 Nov 2005 15:25:22 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Gabriel Becedillas In-Reply-To: <1139bd2a4492e98c3fcf367d5dc1ba00@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: freebsd-threads@freebsd.org Subject: Re: pthreads and segmentation fault X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2005 20:25:25 -0000 On Fri, 11 Nov 2005, Gabriel Becedillas wrote: > Hi, > I'm getting a segmentation fault on FreeBSD 5.4 using pthreads. I was > googling around and found that there are a lot of people hitting the > same bug, but didn't found a solution to it yet. > The active threads on my application are this ones: Are you fork()ing? Are you doing something silly like linking with "-lc -lpthread"? Without a test program to demonstrate the problem, there is nothing much we can do. -- DE From owner-freebsd-threads@FreeBSD.ORG Sat Nov 12 16:00:58 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8F94A16A420; Sat, 12 Nov 2005 16:00:58 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id E881743D53; Sat, 12 Nov 2005 16:00:57 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.5/8.13.5/NETPLEX) with ESMTP id jACG0uQT004341; Sat, 12 Nov 2005 11:00:56 -0500 (EST) Date: Sat, 12 Nov 2005 11:00:56 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Alexander Nedotsukov In-Reply-To: <43721989.3030802@FreeBSD.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; FORMAT=flowed Content-ID: X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: freebsd-threads@freebsd.org Subject: Re: bogus pthread_cond_wait stub? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2005 16:00:58 -0000 On Thu, 10 Nov 2005, Alexander Nedotsukov wrote: > Guys, > > Doesn't patch attached look reasonable for you? From my deletant point > of view :-) this seems to be the culprit of mysterious crashes in > multithreaded plugins loaded by singlethreaded program. Committed, thanks. -- DE