|
From: Johannes B. <joh...@si...> - 2006-06-13 16:23:36
|
I have a trivial test program that looks like this:
#define GC_THREADS 1
#include <signal.h>
#include <gc.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
static void *thr(void *n)
{
int x;
stack_t st;
st.ss_flags = 0;
st.ss_size = 1024*1024;
st.ss_sp = calloc(st.ss_size, 1);
fprintf(stderr,"alternate stack 0x%x\n", st.ss_sp);
sigaltstack(&st, (stack_t*)st.ss_sp);
fprintf(stderr,"thr: stack base is 0x%X\n", (int)&x);
while (1) {
sleep(1);
fprintf(stderr, "thread executing\n");
GC_malloc(100);
}
return NULL;
}
int main()
{
int x = 0;
void *p;
{
size_t size;
void *sstart;
pthread_attr_t attr;
pthread_getattr_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, &sstart, &size);
fprintf (stderr,"stackbottom pth is: %p\n", (char*)sstart + size);
GC_stackbottom = (char*)sstart + size;
}
{
int stack_bottom = (int)&x;
stack_bottom += 4095;
stack_bottom &= ~4095;
fprintf (stderr,"stackbottom is: %p\n", (char*)stack_bottom);
GC_stackbottom = (char*)stack_bottom;
}
GC_INIT();
p = GC_malloc(100);
GC_stop_world();
GC_start_world();
p = GC_malloc(100);
pthread_t t;
pthread_create(&t, NULL, thr, NULL);
pthread_create(&t, NULL, thr, NULL);
sleep(2);
GC_stop_world();
GC_start_world();
sleep(2);
return 0;
}
I'm linking it against libmonogc as shipped in mono, as such:
cc -o test test.c -lmonogc -I /var/tmp/mono-new/mono-1.1.13.6/libgc/include/ -L /var/tmp/mono-new/mono-1.1.13.6/libgc/.libs/ -lpthread
Then I run it on my ppc64 machine with two dual-core CPUs, so all 3
threads are actually executing in parallel. Every once a while, it'll
crash with the trace below.
The valgrind version is 3.1.1-Debian, kernel is 2.6.17-rc5.
==22710== Nulgrind, a binary JIT-compiler.
==22710== Copyright (C) 2002-2005, and GNU GPL'd, by Nicholas Nethercote.
==22710== Using LibVEX rev 1575, a library for dynamic binary translation.
==22710== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==22710== Using valgrind-3.1.1-Debian, a dynamic binary instrumentation framework.
==22710== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==22710== For more details, rerun with: -v
==22710==
--22710-- Max kernel-supported signal is 64
--22710-- signal 11 arrived ... si_code=1, EIP=0x410BE24, eip=0x478752C
--22710-- SIGSEGV: si_code=1 faultaddr=0xFEC14F40 tid=1 ESP=0xFEC14F40 seg=0xFE416000-0xFEC14FFF
--22710-- -> extended stack base to 0xFEC14000
++22710++ sys_sigaction: sigNo 32, new 0xFEC152B8, old 0x0, new flags 0x0
++22710++ sys_sigaction: sigNo 33, new 0xFEC152B8, old 0x0, new flags 0x0
++22710++ sys_sigaction: sigNo 34, new 0xFEC152B8, old 0x0, new flags 0x0
++22710++ do_setmask: tid = 1 how = 0 (SIG_BLOCK), set = 0xFEC153FC 0000000080000000
++22710++ do_setmask: tid = 1 how = 1 (SIG_UNBLOCK), set = 0xFEC153FC 0000000100000000
--22710-- signal 11 arrived ... si_code=1, EIP=0xFE59694, eip=0x47CFAA8
--22710-- SIGSEGV: si_code=1 faultaddr=0xFEC13040 tid=1 ESP=0xFEC13040 seg=0xFE416000-0xFEC13FFF
--22710-- -> extended stack base to 0xFEC13000
--22710-- signal 11 arrived ... si_code=1, EIP=0xFE59694, eip=0x47D05BC
--22710-- SIGSEGV: si_code=1 faultaddr=0xFEC109F0 tid=1 ESP=0xFEC109F0 seg=0xFE416000-0xFEC12FFF
--22710-- -> extended stack base to 0xFEC10000
stackbottom pth is: 0xfec16000
stackbottom is: 0xfec16000
++22710++ sys_sigaction: sigNo 30, new 0xFEC15398, old 0x0, new flags 0x10000000
++22710++ sys_sigaction: sigNo 24, new 0xFEC15398, old 0x0, new flags 0x10000000
++22711++ do_setmask: tid = 2 how = 2 (SIG_SETMASK), set = 0x10037EA0 FFFFFFFEFFFFFFEF
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC1562C 0000000080000000
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15588 0000000080000000
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x10038CF8 0000000080000000
alternate stack 0x5a11008
----22711-- 22710-- kill: sent signal 32 to pid 22710
async_signalhandler ( 32 ) for tid 1 info 0
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC1562C 0000000080000000
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15588 0000000080000000
++22712++ sys_sigaltstack: tid 3, ss 0x5A10ECC, oss 0x5A11008 (current SP 0x5A10EC0)
thr: stack base is 0x5A10EC8
++22712++ do_setmask: tid = 3 how = 0 (SIG_BLOCK), set = 0x5A10D00 0000000000010000
++22712++ oldset=0x5A10D80 0000000080000000
++22712++ sys_sigaction: sigNo 17, new 0x0, old 0x5A10B74, new flags 0x0
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x5A10D80 0000000080000000
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x100398D8 0000000080000000
alternate stack 0x656e008
--22711-- kill: sent signal 32 to pid 22710
++22713++ sys_sigaltstack: tid 4, ss 0x656DECC, oss 0x656E008 (current SP 0x656DEC0)
thr: stack base is 0x656DEC8
++22713++ do_setmask: tid = 4 how = 0 (SIG_BLOCK), set = 0x656DD00 0000000000010000
++22713++ oldset=0x656DD80 0000000080000000
++22713++ sys_sigaction: sigNo 17, new 0x0, old 0x656DB74, new flags 0x0
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x656DD80 0000000080000000
--22710-- async_signalhandler ( 32 ) for tid 1 info 0
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
++22710++ do_setmask: tid = 1 how = 0 (SIG_BLOCK), set = 0xFEC15560 0000000000010000
++22710++ oldset=0xFEC155E0 0000000080000000
++22710++ sys_sigaction: sigNo 17, new 0x0, old 0xFEC153D4, new flags 0x0
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0xFEC155E0 0000000080000000
thread executing
++22712++ do_setmask: tid = 3 how = 0 (SIG_BLOCK), set = 0x5A10D00 0000000000010000
++22712++ oldset=0x5A10D80 0000000080000000
++22712++ sys_sigaction: sigNo 17, new 0x0, old 0x5A10B74, new flags 0x0
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x5A10D80 0000000080000000
thread executing
++22713++ do_setmask: tid = 4 how = 0 (SIG_BLOCK), set = 0x656DD00 0000000000010000
++22713++ oldset=0x656DD80 0000000080000000
++22713++ sys_sigaction: sigNo 17, new 0x0, old 0x656DB74, new flags 0x0
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x656DD80 0000000080000000
thread executing
++22712++ do_setmask: tid = 3 how = 0 (SIG_BLOCK), set = 0x5A10D00 0000000000010000
++22712++ oldset=0x5A10D80 0000000080000000
++22712++ sys_sigaction: sigNo 17, new 0x0, old 0x5A10B74, new flags 0x0
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x5A10D80 0000000080000000
thread executing
++22713++ do_setmask: tid = 4 how = 0 (SIG_BLOCK), set = 0x656DD00 0000000000010000
++22713++ oldset=0x656DD80 0000000080000000
++22713++ sys_sigaction: sigNo 17, new 0x0, old 0x656DB74, new flags 0x0
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x656DD80 0000000080000000
--22710-- kill: sent signal 30 to pid 22712
--22710-- kill: sent signal 30 to pid 22713
--22713-- async_signalhandler ( 30 ) for tid 4 info 0
--22712-- async_signalhandler ( 30 ) for tid 3 info 0
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15618 0000000080000000
--22712-- Async handler got signal 30 for tid 3 info 0
--22712-- delivering signal 30 (SIGPWR):0 to thread 3
--22712-- push_signal_frame (thread 3): signal 30
--22713-- Async handler got signal 30 for tid 4 info 0
--22713-- delivering signal 30 (SIGPWR):0 to thread 4
--22713-- push_signal_frame (thread 4): signal 30
----22710-- async_signalhandler ( 32 ) for tid 1 info 0
22711-- kill: sent signal 32 to pid 22710
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15618 0000000080000000
----22710-- async_signalhandler ( 32 ) for tid 1 info 0
22711-- kill: sent signal 32 to pid 22710
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
--22710-- --22712-- async_signalhandler ( 24 ) for tid 3 info 0
kill: sent signal 24 to pid 22712
--22710-- --22713-- async_signalhandler ( 24 ) for tid 4 info 0
kill: sent signal 24 to pid 22713
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15628 0000000080000000
--22713-- Async handler got signal 24 for tid 4 info 0
--22713-- delivering signal 24 (SIGXCPU):0 to thread 4
--22713-- push_signal_frame (thread 4): signal 24
--22713-- vg_pop_signal_frame (thread 4): isRT=0 valid magic; EIP=0xFE468B4
--22712-- Async handler got signal 24 for tid 3 info 0
--22712-- delivering signal 24 (SIGXCPU):0 to thread 3
--22712-- push_signal_frame (thread 3): signal 24
--22712-- vg_pop_signal_frame (thread 3): isRT=0 valid magic; EIP=0xFE468B4
--22712-- vg_pop_signal_frame (thread 3): isRT=0 valid magic; EIP=0xFEAD124
thread executing
--22713-- vg_pop_signal_frame (thread 4): isRT=0 valid magic; EIP=0xFEAD124
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22713++ oldset=0x656B718 0000000080000000
--22711-- kill: sent signal 32 to pid 22710
--22710-- async_signalhandler ( 32 ) for tid 1 info 0
----22712-- kill: sent signal 32 to pid 22713
22713-- async_signalhandler ( 32 ) for tid 4 info 0
++22712++ do_setmask: tid = 3 how = 0 (SIG_BLOCK), set = 0x5A10D00 0000000000010000
++22712++ oldset=0x5A10D80 0000000080000000
++22712++ sys_sigaction: sigNo 17, new 0x0, old 0x5A10B74, new flags 0x0
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x5A10D80 0000000080000000
--22713-- Async handler got signal 32 for tid 4 info 0
--22713-- delivering signal 32 (SIGRT0):0 to thread 4
--22713-- push_signal_frame (thread 4): signal 32
--22713-- vg_pop_signal_frame (thread 4): isRT=0 valid magic; EIP=0xFF75FB0
thread executing
++22713++ do_setmask: tid = 4 how = 0 (SIG_BLOCK), set = 0x656DD00 0000000000010000
++22713++ oldset=0x656DD80 0000000080000000
++22713++ sys_sigaction: sigNo 17, new 0x0, old 0x656DB74, new flags 0x0
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x656DD80 0000000080000000
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
++22710++ do_setmask: tid = 1 how = 0 (SIG_BLOCK), set = 0xFEC15560 0000000000010000
++22710++ oldset=0xFEC155E0 0000000080000000
++22710++ sys_sigaction: sigNo 17, new 0x0, old 0xFEC153D4, new flags 0x0
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0xFEC155E0 0000000080000000
thread executing
++22712++ do_setmask: tid = 3 how = 0 (SIG_BLOCK), set = 0x5A10D00 0000000000010000
++22712++ oldset=0x5A10D80 0000000080000000
++22712++ sys_sigaction: sigNo 17, new 0x0, old 0x5A10B74, new flags 0x0
++22712++ do_setmask: tid = 3 how = 2 (SIG_SETMASK), set = 0x5A10D80 0000000080000000
thread executing
++22713++ do_setmask: tid = 4 how = 0 (SIG_BLOCK), set = 0x656DD00 0000000000010000
++22713++ oldset=0x656DD80 0000000080000000
++22713++ sys_sigaction: sigNo 17, new 0x0, old 0x656DB74, new flags 0x0
++22713++ do_setmask: tid = 4 how = 2 (SIG_SETMASK), set = 0x656DD80 0000000080000000
thread executing
++22710++ do_setmask: tid = 1 how = 2 (SIG_SETMASK), set = 0x0 0000000000000000
++22710++ oldset=0xFEC15608 0000000080000000
--22711-- --kill: sent signal 33 to pid 22713
22713-- async_signalhandler ( 33 ) for tid 4 info 0
valgrind: m_signals.c:1418 (async_signalhandler): Assertion 'tst->status == VgTs_WaitSys' failed.
--22711-- kill: sent signal 33 to pid 22712
==22713== at 0x700507B4: report_and_quit (m_libcassert.c:122)
==22713== by 0x70050A34: vgPlain_assert_fail (m_libcassert.c:185)
==22713== by 0x7000C48C: async_signalhandler (m_signals.c:1418)
==22713== by 0x10037C: ???
==22713== by 0x7005302C: vgPlain_gettid (m_libcproc.c:334)
==22713== by 0x70050EE4: vgPlain_read (m_libcfile.c:98)
==22713== by 0x700265C0: vgModuleLocal_sema_down (sema.c:71)
==22713== by 0x70023B9C: vgPlain_set_running (scheduler.c:200)
==22713== by 0x7003A5B0: vgPlain_client_syscall (syswrap-main.c:751)
==22713== by 0x70024FD0: handle_syscall (scheduler.c:623)
==22713== by 0x7002544C: vgPlain_scheduler (scheduler.c:726)
==22713== by 0x7003BB38: thread_wrapper (syswrap-linux.c:86)
==22713== by 0x7003BC9C: run_a_thread_NORETURN (syswrap-linux.c:119)
==22713== by 0x7003BE14: vgModuleLocal_start_thread_NORETURN (syswrap-linux.c:206)
==22713== by 0x70048820: (within /usr/lib/valgrind/ppc32-linux/none)
sched status:
running_tid=2
Thread 1: status = VgTs_WaitSys
==22713== at 0xFF75FB0: __pthread_sigsuspend (pt-sigsuspend.c:54)
==22713== by 0xFF751E4: __pthread_wait_for_restart_signal (pthread.c:1216)
==22713== by 0xFF752B8: pthread_onexit_process (restart.h:34)
==22713== by 0xFE49340: exit (exit.c:54)
==22713== by 0xFE2FF74: (below main) (libc-start.c:240)
Thread 2: status = VgTs_Runnable
==22713== at 0xFF7B38C: waitpid (in /usr/lib/debug/libpthread-0.10.so)
==22713== by 0xFF73A8C: __pthread_manager (manager.c:1069)
Thread 3: status = VgTs_Runnable
==22713== at 0xFEAD124: nanosleep (in /usr/lib/debug/libc-2.3.6.so)
==22713== by 0xFEACEFC: sleep (sleep.c:138)
==22713== by 0x10001088: thr (in /tmp/test)
==22713== by 0x10009D84: GC_start_routine (pthread_support.c:1331)
==22713== by 0xFF72F70: pthread_start_thread (manager.c:310)
==22713== by 0xFEE1FC0: clone (clone.S:118)
Thread 4: status = VgTs_Runnable
==22713== at 0xFED0ED8: write (in /usr/lib/debug/libc-2.3.6.so)
==22713== by 0xFE810D4: _IO_file_write@@GLIBC_2.1 (fileops.c:1260)
==22713== by 0xFE7F64C: new_do_write (fileops.c:514)
==22713== by 0xFE813A0: _IO_file_xsputn@@GLIBC_2.1 (fileops.c:1350)
==22713== by 0xFE59808: vfprintf (vfprintf.c:2144)
==22713== by 0xFE61B5C: fprintf (fprintf.c:32)
==22713== by 0x100010A4: thr (in /tmp/test)
==22713== by 0x10009D84: GC_start_routine (pthread_support.c:1331)
==22713== by 0xFF72F70: pthread_start_thread (manager.c:310)
==22713== by 0xFEE1FC0: clone (clone.S:118)
Note: see also the FAQ.txt in the source distribution.
It contains workarounds to several common problems.
If that doesn't help, please report this bug to: www.valgrind.org
In the bug report, send all the above text, the valgrind
version, and what Linux distro you are using. Thanks.
--22712-- async_signalhandler ( 33 ) for tid 3 info 0
--22711-- async_signalhandler ( 33 ) for tid 2 info 1
--22711-- Async handler got signal 33 for tid 2 info 1
--22711-- delivering signal 33 (SIGRT1):1 to thread 2
--22711-- push_signal_frame (thread 2): signal 33
--22711-- vg_pop_signal_frame (thread 2): isRT=0 valid magic; EIP=0xFF7B3C0
--22711-- poll_signals: got signal 33 for thread 2
--22711-- Polling found signal 33 for tid 2
--22711-- delivering signal 33 (SIGRT1):1 to thread 2
--22711-- push_signal_frame (thread 2): signal 33
--22711-- vg_pop_signal_frame (thread 2): isRT=0 valid magic; EIP=0xFF7B3C0
--22711-- kill: sent signal 32 to pid 22710
--22710-- async_signalhandler ( 32 ) for tid 1 info 0
--22710-- Async handler got signal 32 for tid 1 info 0
--22710-- delivering signal 32 (SIGRT0):0 to thread 1
--22710-- push_signal_frame (thread 1): signal 32
--22710-- vg_pop_signal_frame (thread 1): isRT=0 valid magic; EIP=0xFF75FB0
|