From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Trouble joining with threads from C Date: Fri, 15 Apr 2011 10:41:42 +0200 Message-ID: References: <87y64rzd5p.fsf@netris.org> <8762rswzzf.fsf@netris.org> <87vczdqtdx.fsf@gnu.org> <87ipuhzvvk.fsf@gnu.org> <877haxzvh6.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1302863903 30295 80.91.229.12 (15 Apr 2011 10:38:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Apr 2011 10:38:23 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 15 12:38:19 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QAgPp-000250-Je for guile-devel@m.gmane.org; Fri, 15 Apr 2011 12:38:17 +0200 Original-Received: from localhost ([::1]:43675 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAgPo-0001ed-WD for guile-devel@m.gmane.org; Fri, 15 Apr 2011 06:38:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAgPl-0001eT-QY for guile-devel@gnu.org; Fri, 15 Apr 2011 06:38:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAgPk-0008Jc-G5 for guile-devel@gnu.org; Fri, 15 Apr 2011 06:38:13 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:62614 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAgPk-0008J5-DS; Fri, 15 Apr 2011 06:38:12 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 5DAC63DD2; Fri, 15 Apr 2011 06:40:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=pBYQ7oCBU37G nRWgVPnyQwRf3D4=; b=h3wDKVxVsTNne8fIv9cJ2usXPYfPGeg5ftOS55lm7U6c YQ4ZwWE37Cr6THJpuwEhRgJ9OXPEKTyDPaMH2mGFtQqWG+z7PdyXHZ8BY7eJ4qTI ayG7X7tBH1rdICA1gbiV3R6T19Y2H0E4IyhrawxnuDsvT/lYk+6fo+H0URISlDo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=KOeufe MEUv3cgHLrhAosJcYEGNECRjbZQGCHQnXvgOVzEbTu97bgrrAYPdDbldYDQm3BFy g2rVvT6vHslijJ4TLE4PD8ZE33rFQw2Xc/Yhqw2KNSy/8rhmYbIilJ/czjPwxm8j Q2KAkF+U2vlY9wG6HeOVlPshf1Akx8019TDZQ= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 4AFDE3DD0; Fri, 15 Apr 2011 06:40:04 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 7C5703DCB; Fri, 15 Apr 2011 06:40:02 -0400 (EDT) In-Reply-To: <877haxzvh6.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Wed, 13 Apr 2011 23:34:29 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: B91E1B2C-674C-11E0-B001-E8AB60295C12-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12265 Archived-At: Hi Ludovic, On Wed 13 Apr 2011 23:34, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > After reviewing f60a7648d5926555c7760364a6fbb7dc0cf60720 (which > addressed the same issue), I lean towards reverting it and instead > applying the patch I just sent. > > The problem I see with f60a7648d5926555c7760364a6fbb7dc0cf60720 is that > it re-introduces a pthread_key, even when using TLS, and make things a > bit complex IMO. The issue is that threads in Guile are not always spawned by Guile. It's true that of the two cases in which Guile spawned a thread, one of them wasn't getting the cleanup handlers called, and your patch fixes that; but that ignores the case of threads that are spawned by a user's program. For example in the following program: void* thread (void*) { scm_with_guile (do_something, NULL); scm_with_guile (do_something_else, NULL); return NULL; } int main () { pthread_t thr; pthread_create (&thr, NULL, thread, NULL); pthread_join (thr, NULL); return 0; } When do you propose that the cleanup handlers for the thread be called? As far as I understand things, reliably cleaning up after the thread *requires* the use of pthread_key with a destructor. It is the only way to attach a cleanup callback to a thread. It's true that the key is not used when TLS is available, except for its destructor capabilities, but it is not more complicated than before. I think they context that you are missing here is bug 32436. It does appear that I have introduced some bugs here: Mark's after-gc-hook not being called, and a failure to build --without-threads. For that I apologize. But these bugs are fixable. Consider bug 32436 for a moment: you can't fix that with pthread_cleanup_push. Does this explanation help? Let me know, Andy --=20 http://wingolog.org/