From: Ivo Raisr Date: Sat, 23 Apr 2016 19:35:11 +0000 (+0000) Subject: Fix Valgrind coredump when VG_(unimplemented)() is called X-Git-Tag: svn/VALGRIND_3_12_0~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d4c5ae3d611316a1a0e5a959a0627e68387689b;p=thirdparty%2Fvalgrind.git Fix Valgrind coredump when VG_(unimplemented)() is called early during main initialization, before the threads are created and scheduler is initialized. Fixes BZ#362009 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15867 --- diff --git a/NEWS b/NEWS index 5f39676adc..cbeb9d8d92 100644 --- a/NEWS +++ b/NEWS @@ -86,6 +86,8 @@ where XXXXXX is the bug number as listed below. 359829 PowerPC test none/tests/ppc64/test_isa_2_07.c uninitialized memory references was fixed. 359871 Incorrect mask handling in ppoll +360008 Contents of Power vr registers contents is not printed correctly when + the --vgdb-shadow-registers=yes option is used 360425 arm64 unsupported instruction ldpsw 360519 none/tests/arm64/memory.vgtest might fail with newer gcc 360749 kludge for multiple .rodata sections on Solaris no longer needed @@ -93,8 +95,7 @@ where XXXXXX is the bug number as listed below. 361354 ppc64[le]: wire up separate socketcalls system calls 361226 s390x: risbgn (EC59) not implemented 361926 Unhandled Solaris syscall: sysfs(84) -360008 Contents of Power vr registers contents is not printed correctly when - the --vgdb-shadow-registers=yes option is used +362009 Valgrind dumps core on unimplemented functionality before threads are created n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 and amd64 n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index c393d7b73b..b5ce2d9c9f 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -362,38 +362,42 @@ static void show_sched_status_wrk ( Bool host_stacktrace, } VG_(printf)("\nsched status:\n"); - VG_(printf)(" running_tid=%u\n", VG_(get_running_tid)()); - for (i = 1; i < VG_N_THREADS; i++) { - VgStack* stack - = (VgStack*)VG_(threads)[i].os_state.valgrind_stack_base; - /* If a thread slot was never used (yet), valgrind_stack_base is 0. - If a thread slot is used by a thread or was used by a thread which - has exited, then valgrind_stack_base points to the stack base. */ - if (VG_(threads)[i].status == VgTs_Empty - && (!exited_threads || stack == 0)) continue; - VG_(printf)("\nThread %d: status = %s (lwpid %d)\n", i, - VG_(name_of_ThreadStatus)(VG_(threads)[i].status), - VG_(threads)[i].os_state.lwpid); - if (VG_(threads)[i].status != VgTs_Empty) - VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH ); - if (stack_usage && VG_(threads)[i].client_stack_highest_byte != 0 ) { - Addr start, end; - - start = end = 0; - VG_(stack_limits)(VG_(threads)[i].client_stack_highest_byte, - &start, &end); - if (start != end) - VG_(printf)("client stack range: [%p %p] client SP: %p\n", - (void*)start, (void*)end, (void*)VG_(get_SP)(i)); - else - VG_(printf)("client stack range: ???????\n"); + if (VG_(threads) == NULL) { + VG_(printf)(" scheduler not yet initialised\n"); + } else { + VG_(printf)(" running_tid=%u\n", VG_(get_running_tid)()); + for (i = 1; i < VG_N_THREADS; i++) { + VgStack *stack + = (VgStack*)VG_(threads)[i].os_state.valgrind_stack_base; + /* If a thread slot was never used (yet), valgrind_stack_base is 0. + If a thread slot is used by a thread or was used by a thread which + has exited, then valgrind_stack_base points to the stack base. */ + if (VG_(threads)[i].status == VgTs_Empty + && (!exited_threads || stack == 0)) continue; + VG_(printf)("\nThread %d: status = %s (lwpid %d)\n", i, + VG_(name_of_ThreadStatus)(VG_(threads)[i].status), + VG_(threads)[i].os_state.lwpid); + if (VG_(threads)[i].status != VgTs_Empty) + VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH ); + if (stack_usage && VG_(threads)[i].client_stack_highest_byte != 0 ) { + Addr start, end; + + start = end = 0; + VG_(stack_limits)(VG_(threads)[i].client_stack_highest_byte, + &start, &end); + if (start != end) + VG_(printf)("client stack range: [%p %p] client SP: %p\n", + (void*)start, (void*)end, (void*)VG_(get_SP)(i)); + else + VG_(printf)("client stack range: ???????\n"); + } + if (stack_usage && stack != 0) + VG_(printf)("valgrind stack top usage: %lu of %lu\n", + VG_(clo_valgrind_stacksize) + - VG_(am_get_VgStack_unused_szB) + (stack, VG_(clo_valgrind_stacksize)), + (SizeT) VG_(clo_valgrind_stacksize)); } - if (stack_usage && stack != 0) - VG_(printf)("valgrind stack top usage: %lu of %lu\n", - VG_(clo_valgrind_stacksize) - - VG_(am_get_VgStack_unused_szB) - (stack, VG_(clo_valgrind_stacksize)), - (SizeT) VG_(clo_valgrind_stacksize)); } VG_(printf)("\n"); } diff --git a/none/tests/solaris/reserve_sysstat_addr.stderr.exp b/none/tests/solaris/reserve_sysstat_addr.stderr.exp index 05d2cc671a..73ba489cff 100644 --- a/none/tests/solaris/reserve_sysstat_addr.stderr.exp +++ b/none/tests/solaris/reserve_sysstat_addr.stderr.exp @@ -11,4 +11,5 @@ Valgrind has to exit now. Sorry. Bye! sched status: - running_tid=0 + scheduler not yet initialised + diff --git a/none/tests/solaris/reserve_sysstat_addr.vgtest b/none/tests/solaris/reserve_sysstat_addr.vgtest index 01ece7e61f..c3e8d14e7b 100644 --- a/none/tests/solaris/reserve_sysstat_addr.vgtest +++ b/none/tests/solaris/reserve_sysstat_addr.vgtest @@ -1,4 +1,3 @@ prereq: test -e reserve_sysstat_addr prog: reserve_sysstat_addr vgopts: -q -cleanup: rm -f core diff --git a/none/tests/solaris/reserve_sysstat_zone_addr.stderr.exp b/none/tests/solaris/reserve_sysstat_zone_addr.stderr.exp index e907920471..32b0439af2 100644 --- a/none/tests/solaris/reserve_sysstat_zone_addr.stderr.exp +++ b/none/tests/solaris/reserve_sysstat_zone_addr.stderr.exp @@ -11,4 +11,5 @@ Valgrind has to exit now. Sorry. Bye! sched status: - running_tid=0 + scheduler not yet initialised + diff --git a/none/tests/solaris/reserve_sysstat_zone_addr.vgtest b/none/tests/solaris/reserve_sysstat_zone_addr.vgtest index 012b290064..e48b278867 100644 --- a/none/tests/solaris/reserve_sysstat_zone_addr.vgtest +++ b/none/tests/solaris/reserve_sysstat_zone_addr.vgtest @@ -1,4 +1,3 @@ prereq: test -e reserve_sysstat_zone_addr prog: reserve_sysstat_zone_addr vgopts: -q -cleanup: rm -f core