From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Maidanski Newsgroups: gmane.comp.programming.garbage-collection.boehmgc,gmane.lisp.guile.bugs Subject: =?utf-8?Q?Re=3A__further_pthread_foo?= Date: Sun, 20 Mar 2011 00:25:52 +0300 Message-ID: References: Reply-To: Ivan Maidanski NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1300570192 19725 80.91.229.12 (19 Mar 2011 21:29:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2011 21:29:52 +0000 (UTC) Cc: bug-guile , gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org To: Andy Wingo Original-X-From: gc-bounces-V9/bV5choksm30D7ZfaTJw@public.gmane.org Sat Mar 19 22:29:48 2011 Return-path: Envelope-to: gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org Original-Received: from gundega.hpl.hp.com ([192.6.19.190]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q13iV-0002BU-LZ for gcpgb-gc-Uylq5CNFT+jYtjvyW6yDsg@public.gmane.org; Sat, 19 Mar 2011 22:29:48 +0100 Original-Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by gundega.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id p2JLTIZX006151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 19 Mar 2011 14:29:18 -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 p2JLTFH3006908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 19 Mar 2011 14:29:15 -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 p2JLQPMG002302; Sat, 19 Mar 2011 13:26:28 -0800 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 p2JLQMif002299 for ; Sat, 19 Mar 2011 13:26:22 -0800 Original-Received: from f78.mail.ru (f78.mail.ru [217.69.128.226]) by madara.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id p2JLQ7hE006366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 19 Mar 2011 14:26:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Message-Id:Content-Transfer-Encoding:Content-Type:Reply-To:In-Reply-To:References:Date:Mime-Version:Subject:Cc:To:From; bh=Osa2dDNBrrXzfUxDb5UQO1UZcJiIQuir6/uUi6+lOP4=; b=14uRhXyIxTg34dCo9MB1HOnVqKkvnh3mFJDO0LOA+JAwXE+EARcDLXosfJiPa20BMGhKlTW70Si9OlJqKN6sMYSOpQHkkwKL2/l9qvOEiPlS7Pd9asP4eBJ1rSyAQ9vN; Original-Received: from mail by f78.mail.ru with local id 1Q13ei-0001TJ-00; Sun, 20 Mar 2011 00:25:52 +0300 Original-Received: from [109.225.46.145] by e.mail.ru with HTTP; Sun, 20 Mar 2011 00:25:52 +0300 X-Mailer: mPOP Web-Mail 2.19 X-Originating-IP: [109.225.46.145] In-Reply-To: X-Spam: Not detected X-Mras: Ok X-Scanned-By: MIMEDefang 2.71 on 15.0.48.190 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 Xref: news.gmane.org gmane.comp.programming.garbage-collection.boehmgc:4436 gmane.lisp.guile.bugs:5346 Archived-At: Hi Andy, Try to compile libgc with -DGC_ASSERTIONS but without -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK. I cannot help you more in figuring out what's the problem (due to lack of time). Probably someone else could help you more... BTW. Why do you use GC_call_with_gc_active()? It should be no-op in your case - the thread is stopped and scanned after you call GC_register_my_thread. (GC_call_with_gc_active is used primarily inside GC_do_blocking calls). Fri, 18 Mar 2011 23:26:30 +0100 Andy Wingo : > Hello again! > > Continuing on the same topic as my previous mail, which you may read > here: > > http://thread.gmane.org/gmane.lisp.guile.bugs/5340 > > I modified the program to do a `scm_init_guile ()' before creating any > threads. This initializes libgc from the main thread, so all should be > well. But then I run into a problem: > > (gdb) r > Starting program: /tmp/many_threads > [Thread debugging using libthread_db enabled] > 0: create[New Thread 0x7ffff740b700 (LWP 23030)] > join > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7ffff740b700 (LWP 23030)] > 0x00007ffff7a09200 in GC_malloc (bytes=16) at thread_local_alloc.c:161 > 161 GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES, > (gdb) thr apply all bt > Thread 2 (Thread 0x7ffff740b700 (LWP 23030)): > #0 0x00007ffff7a09200 in GC_malloc (bytes=16) at thread_local_alloc.c:161 > #1 0x00007ffff7d1208e in scm_cell (x=, y= optimized out>) at ../libguile/inline.h:124 > #2 scm_cons (x=, y=) at pairs.c:77 > #3 0x00007ffff7cd05b7 in scm_i_with_continuation_barrier (body=0x7ffff7cd03a0 > , body_data=0x7ffff740adb0, > handler=0x7ffff7cd03c0 , handler_data=0x7ffff740adb0, > pre_unwind_handler=, > pre_unwind_handler_data=) at continuations.c:444 > #4 0x00007ffff7cd0690 in scm_c_with_continuation_barrier (func= optimized out>, data=) > at continuations.c:491 > #5 0x00007ffff7a0982f in GC_call_with_gc_active (fn=0x7ffff7d48740 > , client_data=0x7ffff740ae20) > at pthread_support.c:1127 > #6 0x00007ffff7d48aed in with_gc_active (func=0x7ffff7d488e0 > , data=0x949600, parent=) > at threads.c:97 > #7 scm_i_with_guile_and_parent (func=0x7ffff7d488e0 , > data=0x949600, parent=) > at threads.c:826 > #8 0x00007ffff7d48bc7 in do_thread_exit_trampoline (sb=, > v=0x949600) at threads.c:549 > #9 0x00007ffff7a03525 in GC_call_with_stack_base (fn=, > arg=) at misc.c:1493 > #10 0x00007ffff7d48867 in on_thread_exit (v=0x949600) at threads.c:580 > #11 0x0000003fc86077f9 in __nptl_deallocate_tsd (arg=0x7ffff740b700) at > pthread_create.c:154 > #12 start_thread (arg=0x7ffff740b700) at pthread_create.c:308 > #13 0x0000003fc7ee098d in clone () at > ../sysdeps/unix/sysv/linux/x86_64/clone.S:115 > > Thread 1 (Thread 0x7ffff76ce700 (LWP 23027)): > #0 0x0000003fc8607fbd in pthread_join (threadid=140737341601536, > thread_return=0x7fffffffe018) at pthread_join.c:89 > #1 0x00007ffff7a09e47 in GC_pthread_join (thread=140737341601536, > retval=0x7fffffffe018) at pthread_support.c:1219 > #2 0x00000000004008e7 in main () at many_threads.c:31 > > What is happening is that I have registered a pthread_key cleanup > handler, and I need to call a Guile function in that handler. But quite > possibly, libgc has already torn down this thread. So I trampoline > through a GC_call_with_stack_base, then register the current thread. If > that returns GC_SUCCESS, later I unregister it. In between there is the > scm_i_with_guile_and_parent call you see at frame #7. > > However as you see, there is unhappiness there. I don't know what > exactly is causing the segfault, but here's a disassembly: > > (gdb) disassemble $pc > Dump of assembler code for function GC_malloc: > 0x00007ffff7a09180 <+0>: mov %rbx,-0x30(%rsp) > 0x00007ffff7a09185 <+5>: mov %r13,-0x18(%rsp) > 0x00007ffff7a0918a <+10>: mov %rdi,%rbx > 0x00007ffff7a0918d <+13>: mov %rbp,-0x28(%rsp) > 0x00007ffff7a09192 <+18>: mov %r12,-0x20(%rsp) > 0x00007ffff7a09197 <+23>: mov %r14,-0x10(%rsp) > 0x00007ffff7a0919c <+28>: mov %r15,-0x8(%rsp) > 0x00007ffff7a091a1 <+33>: sub $0x48,%rsp > 0x00007ffff7a091a5 <+37>: mov 0x20a104(%rip),%rax # 0x7ffff7c132b0 > 0x00007ffff7a091ac <+44>: mov (%rax),%r12d > 0x00007ffff7a091af <+47>: data32 lea 0x20a3e9(%rip),%rdi # > 0x7ffff7c135a0 > 0x00007ffff7a091b7 <+55>: data32 data32 callq 0x7ffff79f6da0 > <__tls_get_addr@plt> > 0x00007ffff7a091bf <+63>: mov (%rax),%r13 > 0x00007ffff7a091c2 <+66>: test %r13,%r13 > 0x00007ffff7a091c5 <+69>: je 0x7ffff7a0923f > 0x00007ffff7a091c7 <+71>: add $0xf,%r12d > 0x00007ffff7a091cb <+75>: movslq %r12d,%r12 > 0x00007ffff7a091ce <+78>: lea (%rbx,%r12,1),%r12 > 0x00007ffff7a091d2 <+82>: shr $0x4,%r12 > 0x00007ffff7a091d6 <+86>: cmp $0x18,%r12 > 0x00007ffff7a091da <+90>: ja 0x7ffff7a0923f > 0x00007ffff7a091dc <+92>: lea 0x18(%r12),%r14 > 0x00007ffff7a091e1 <+97>: mov %r12,%rbp > 0x00007ffff7a091e4 <+100>: mov $0x10,%r15d > 0x00007ffff7a091ea <+106>: shl $0x4,%rbp > 0x00007ffff7a091ee <+110>: mov 0x8(%r13,%r14,8),%rax > 0x00007ffff7a091f3 <+115>: lea 0x8(%r13,%r14,8),%rcx > 0x00007ffff7a091f8 <+120>: cmp $0x11a,%rax > 0x00007ffff7a091fe <+126>: jbe 0x7ffff7a09269 > => 0x00007ffff7a09200 <+128>: mov (%rax),%rdx > 0x00007ffff7a09203 <+131>: mov %rdx,0x8(%r13,%r14,8) > 0x00007ffff7a09208 <+136>: prefetcht0 (%rdx) > 0x00007ffff7a0920b <+139>: movq $0x0,(%rax) > 0x00007ffff7a09212 <+146>: mov 0x18(%rsp),%rbx > 0x00007ffff7a09217 <+151>: mov 0x20(%rsp),%rbp > 0x00007ffff7a0921c <+156>: mov 0x28(%rsp),%r12 > 0x00007ffff7a09221 <+161>: mov 0x30(%rsp),%r13 > 0x00007ffff7a09226 <+166>: mov 0x38(%rsp),%r14 > 0x00007ffff7a0922b <+171>: mov 0x40(%rsp),%r15 > 0x00007ffff7a09230 <+176>: add $0x48,%rsp > 0x00007ffff7a09234 <+180>: retq > > (gdb) info registers > rax 0x1000 4096 > rbx 0x10 16 > rcx 0x6b1650 7018064 > rdx 0x2 2 > rsi 0x0 0 > rdi 0x6027e0 6301664 > rbp 0x10 0x10 > rsp 0x7ffff740acc0 0x7ffff740acc0 > r8 0x7ffff7d490b0 140737351291056 > r9 0x0 0 > r10 0x7ffff740aba0 140737341598624 > r11 0x7ffff7a097c0 140737347884992 > r12 0x1 1 > r13 0x6b1580 7017856 > r14 0x19 25 > r15 0x10 16 > rip 0x7ffff7a09200 0x7ffff7a09200 > eflags 0x10212 [ AF IF RF ] > cs 0x33 51 > ss 0x2b 43 > ds 0x0 0 > es 0x0 0 > fs 0x0 0 > gs 0x0 0 > > This is with current CVS. > > Regards, > > Andy > -- > http://wingolog.org/ > _______________________________________________ > Gc mailing list > Gc-V9/bV5choksm30D7ZfaTJw@public.gmane.org > http://www.hpl.hp.com/hosted/linux/mail-archives/gc/