From owner-freebsd-arch@FreeBSD.ORG Mon Mar 19 21:05:55 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 88E2916A401; Mon, 19 Mar 2007 21:05:55 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id E41E613C45D; Mon, 19 Mar 2007 21:05:54 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (host5.bedc.ondsl.gr [62.103.39.229]) (authenticated bits=128) by igloo.linux.gr (8.13.8/8.13.8/Debian-3) with ESMTP id l2JL4r6Z002957 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 19 Mar 2007 23:05:00 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.13.8/8.13.8) with ESMTP id l2JL4Z7i011407; Mon, 19 Mar 2007 23:04:47 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.13.8/8.13.8/Submit) id l2JL4Y3g011382; Mon, 19 Mar 2007 23:04:34 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 19 Mar 2007 23:04:34 +0200 From: Giorgos Keramidas To: Dan Nelson Message-ID: <20070319210434.GA7312@kobe.laptop> References: <45F906ED.8070100@aueb.gr> <200703151827.39963.max@love2party.net> <20070318053307.GC73385@funkthat.com> <20070318134900.GA98260@kobe.laptop> <20070318202515.GF64778@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070318202515.GF64778@dan.emsphone.com> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.507, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.69, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: Max Laier , freebsd-arch@freebsd.org, freebsd-threads@freebsd.org Subject: Re: Multithreaded qsort(3) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2007 21:05:55 -0000 On 2007-03-18 15:25, Dan Nelson wrote: >In the last episode (Mar 18), Giorgos Keramidas said: >>On 2007-03-17 23:43, Kip Macy wrote: >>> Reminds me of how Solaris blindly uses vfork for implementing >>> system(3). It was very easy for a naive user (me) to call system >>> from a multi-threaded python application. I had numerous failures >>> that were impossible to track back to system(3). >> >> It seems like an 'obvious' optimization, though. vfork() will block >> the parent process until the child runs exec(), and the whole purpose >> of system is to exec() a shell and run an external command. >> >> Can you elaborate on the problems you were seeing? It sounds like >> something both interesting and educational :) > > Btw - the Solaris 10 system manpage only mentions signal interactions > as the cause for MT-unsafeness: > > "The system() function manipulates the signal handlers for SIGINT, > SIGQUIT, and SIGCHLD. It is therefore not safe to call system() > in a multithreaded process, since some other thread that > manipulates these signal handlers and a thread that concurrently > calls system() can interfere with each other in a destructive > manner. If, however, no such other thread is active, system() can > safely be called concurrently from multiple threads. See > popen(3C) for an alternative to system() that is thread-safe." > > It looks like there were some vfork-related system() bugs in older > versions of Solaris, but they appear to have been fixed: > http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4332595 Thanks! The bug description was a very good read. The interaction with the runtime linker didn't occur to me, but now I see :)