From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo-mXXj517/zsQ@public.gmane.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.comp.programming.garbage-collection.boehmgc,gmane.lisp.guile.bugs Subject: Calling =?utf-8?b?4oCYR0NfcHRocmVhZF9jcmVhdGXigJk=?= from a pthread key destructor Date: Wed, 20 Apr 2011 16:20:08 +0200 Message-ID: <87tydt3syv.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 1303309700 28882 80.91.229.12 (20 Apr 2011 14:28:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 20 Apr 2011 14:28:20 +0000 (UTC) Cc: bug-guile-mXXj517/zsQ@public.gmane.org To: gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org Original-X-From: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org Wed Apr 20 16:28:12 2011 Return-path: Envelope-to: gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org Original-Received: from madara.hpl.hp.com ([192.6.19.124]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QCYO2-0002a8-1U for gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org; Wed, 20 Apr 2011 16:28:10 +0200 Original-Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by madara.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id p3KEQhVv004920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 20 Apr 2011 07:26:44 -0700 Original-Received: from napali.hpl.hp.com (napali.hpl.hp.com [15.4.89.123]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id p3KEQh0h021909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 20 Apr 2011 07:26:43 -0700 Original-Received: from napali.hpl.hp.com (localhost.hpl.hp.com [127.0.0.1]) by napali.hpl.hp.com (8.13.4/8.13.4/HPL-PA send-recv-int) with ESMTP id p3KENtgU013350; Wed, 20 Apr 2011 07:23:57 -0700 Original-Received: from madara.hpl.hp.com (madara.hpl.hp.com [15.0.152.124]) by napali.hpl.hp.com (8.13.4/8.13.4/HPL-PA send-recv-int) with ESMTP id p3KENrZ3013347 for ; Wed, 20 Apr 2011 07:23:53 -0700 Original-Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by madara.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id p3KENeIV004829 for ; Wed, 20 Apr 2011 07:23:48 -0700 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QCYGV-00056U-E6 for gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org; Wed, 20 Apr 2011 16:20:23 +0200 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Apr 2011 16:20:23 +0200 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Apr 2011 16:20:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Followup-To: gmane.comp.programming.garbage-collection.boehmgc Original-Lines: 93 Original-X-Complaints-To: usenet-mkLwACOSqtU9smdsby/KFg@public.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 =?iso-8859-1?Q?Flor=E9al?= an 219 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.110015 (No Gnus v0.15) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:FWoN10AMlyZsIcIwAEj19GEQ8cA= X-Scanned-By: MIMEDefang 2.71 on 15.0.152.124 X-Scanned-By: MIMEDefang 2.71 on 192.6.19.124 X-BeenThere: gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Garbage Collector bugs/discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org Errors-To: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org X-MIME-Autoconverted: from 8bit to quoted-printable by madara.hpl.hp.com id p3KEQhVv004920 Xref: news.gmane.org gmane.comp.programming.garbage-collection.boehmgc:4502 gmane.lisp.guile.bugs:5507 Archived-At: Hello, The program below quickly segfaults on GNU/Linux: --8<---------------cut here---------------start------------->8--- #define GC_THREADS 1 #define GC_NO_THREAD_REDIRECTS 1 #include #include #include #include #include static pthread_key_t key; static pthread_once_t key_once =3D PTHREAD_ONCE_INIT; static void * entry (void *arg) { pthread_setspecific (key, GC_STRDUP ("hello, world")); return arg; } static void on_thread_exit (void *v) { pthread_t t; GC_pthread_create (&t, NULL, entry, NULL); } static void make_key () { pthread_key_create (&key, on_thread_exit); } int main (int argc, char *argv[]) { GC_INIT (); pthread_once (&key_once, make_key); while (1) { pthread_t t; GC_pthread_create (&t, NULL, entry, NULL); } return EXIT_SUCCESS; } --8<---------------cut here---------------end--------------->8--- The backtrace varies, but it=E2=80=99s typically one of: --8<---------------cut here---------------start------------->8--- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fff7d722700 (LWP 1497)] GC_generic_malloc_inner (lb=3D56, k=3D1) at ../malloc.c:127 127 obj_link(op) =3D 0; (gdb) bt #0 GC_generic_malloc_inner (lb=3D56, k=3D1) at ../malloc.c:127 #1 0x00007ffff7b916ef in GC_pthread_create (new_thread=3D0x7fff7d721e98,= attr=3D0x0, start_routine=3D0x400904 , arg=3D0x0) at ../pthread_s= upport.c:1474 #2 0x000000000040095a in on_thread_exit (v=3D0x662d90) at t.c:24 #3 0x00007ffff75f0b29 in __nptl_deallocate_tsd () from /nix/store/vxycd1= 07wjbhcj720hzkw2px7s7kr724-glibc-2.12.2/lib/libpthread.so.0 #4 0x00007ffff75f0cfa in start_thread () from /nix/store/vxycd107wjbhcj7= 20hzkw2px7s7kr724-glibc-2.12.2/lib/libpthread.so.0 #5 0x00007ffff78d81ed in clone () from /nix/store/vxycd107wjbhcj720hzkw2= px7s7kr724-glibc-2.12.2/lib/libc.so.6 --8<---------------cut here---------------end--------------->8--- or: --8<---------------cut here---------------start------------->8--- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fff9274c700 (LWP 1823)] 0x0000000000652fc0 in ?? () (gdb) bt #0 0x0000000000652fc0 in ?? () #1 0x00007ffff7b90791 in GC_inner_start_routine (sb=3D, arg=3D) at ../pthread_start.c:61 #2 0x00007ffff7b8b6b5 in GC_call_with_stack_base (fn=3D, arg=3D) at ../misc.c:1505 #3 0x00007ffff75f0cec in start_thread () from /nix/store/vxycd107wjbhcj7= 20hzkw2px7s7kr724-glibc-2.12.2/lib/libpthread.so.0 #4 0x00007ffff78d81ed in clone () from /nix/store/vxycd107wjbhcj720hzkw2= px7s7kr724-glibc-2.12.2/lib/libc.so.6 --8<---------------cut here---------------end--------------->8--- Replacing =E2=80=98GC_pthread_create=E2=80=99 by =E2=80=98pthread_create=E2= =80=99 in =E2=80=98on_thread_exit=E2=80=99 suffices to avoid the segfault. Any ideas? Is it something we can reasonably expect to work? Thanks, Ludo=E2=80=99. PS: For the record, Guile has a similar problem with =E2=80=98scm_spawn_t= hread=E2=80=99.