|
From: Nicholas N. <nj...@ca...> - 2004-10-13 09:59:02
|
CVS commit by nethercote:
Fix for bug 91162: cope with jumps to bogus addresses when there is a SEGV
signal handler present -- previously, Valgrind would abort unnecessarily on
this case.
Added a regression test for it.
MERGED FROM HEAD
A memcheck/tests/badjump2.c 1.1.2.1 [POSSIBLY UNSAFE: printf] [no copyright]
A memcheck/tests/badjump2.stderr.exp 1.1.2.1
A memcheck/tests/badjump2.vgtest 1.1.2.1
M +1 -1 coregrind/vg_include.h 1.235.2.2
M +17 -5 coregrind/vg_scheduler.c 1.171.2.1
M +4 -2 coregrind/vg_translate.c 1.88.2.1
M +1 -0 memcheck/tests/.cvsignore 1.14.2.1
M +4 -1 memcheck/tests/Makefile.am 1.41.2.1
--- valgrind/coregrind/vg_include.h #1.235.2.1:1.235.2.2
@@ -1161,5 +1161,5 @@ struct _UCodeBlock {
};
-extern void VG_(translate) ( ThreadId tid, Addr orig_addr, Bool debugging );
+extern Bool VG_(translate) ( ThreadId tid, Addr orig_addr, Bool debugging );
extern void VG_(sanity_check_UInstr) ( UInt n, UInstr* u );
--- valgrind/coregrind/vg_scheduler.c #1.171:1.171.2.1
@@ -1022,15 +1022,27 @@ VgSchedReturnCode do_scheduler ( Int* ex
if (trc == VG_TRC_INNER_FASTMISS) {
+ Addr ip = VG_(threads)[tid].m_eip;
+
vg_assert(VG_(dispatch_ctr) > 0);
/* Trivial event. Miss in the fast-cache. Do a full
lookup for it. */
- trans_addr = VG_(search_transtab) ( VG_(threads)[tid].m_eip );
+ trans_addr = VG_(search_transtab) ( ip );
if (trans_addr == (Addr)0) {
/* Not found; we need to request a translation. */
- VG_(translate)( tid, VG_(threads)[tid].m_eip, /*debug*/False );
- trans_addr = VG_(search_transtab) ( VG_(threads)[tid].m_eip );
+ if (VG_(translate)( tid, ip, /*debug*/False )) {
+ trans_addr = VG_(search_transtab)( ip );
if (trans_addr == (Addr)0)
VG_(core_panic)("VG_TRC_INNER_FASTMISS: missing tt_fast entry");
+ } else {
+ // If VG_(translate)() fails, it's because it had to throw
+ // a signal because the client jumped to a bad address.
+ // This means VG_(deliver_signal)() will have been called
+ // by now, and the program counter will now be pointing to
+ // the start of the signal handler (if there is no
+ // handler, things would have been aborted by now), so do
+ // nothing, and things will work out next time around the
+ // scheduler loop.
+ }
}
continue; /* with this thread */
--- valgrind/coregrind/vg_translate.c #1.88:1.88.2.1
@@ -2429,5 +2429,5 @@ static void vg_realreg_liveness_analysis
'tid' is the identity of the thread needing this block.
*/
-void VG_(translate) ( ThreadId tid, Addr orig_addr,
+Bool VG_(translate) ( ThreadId tid, Addr orig_addr,
Bool debugging_translation )
{
@@ -2485,5 +2485,5 @@ void VG_(translate) ( ThreadId tid, Addr
VG_(synth_fault_mapping)(tid, orig_addr);
- return;
+ return False;
} else
seg->flags |= SF_CODE; /* contains cached code */
@@ -2584,4 +2584,6 @@ void VG_(translate) ( ThreadId tid, Addr
VGP_POPCC(VgpTranslate);
+
+ return True;
}
--- valgrind/memcheck/tests/.cvsignore #1.14:1.14.2.1
@@ -4,4 +4,5 @@
badfree
badjump
+badjump2
badloop
buflen_check
--- valgrind/memcheck/tests/Makefile.am #1.41:1.41.2.1
@@ -16,4 +16,5 @@
badfree.stderr.exp badfree.vgtest \
badjump.stderr.exp badjump.vgtest \
+ badjump2.stderr.exp badjump2.vgtest \
badloop.stderr.exp badloop.vgtest \
badrw.stderr.exp badrw.vgtest \
@@ -79,5 +80,6 @@
check_PROGRAMS = \
- badaddrvalue badfree badjump badloop badrw brk brk2 buflen_check \
+ badaddrvalue badfree badjump badjump2 \
+ badloop badrw brk brk2 buflen_check \
clientperm custom_alloc \
doublefree error_counts errs1 exitprog execve execve2 \
@@ -99,4 +101,5 @@
badfree_SOURCES = badfree.c
badjump_SOURCES = badjump.c
+badjump2_SOURCES = badjump2.c
badloop_SOURCES = badloop.c
badrw_SOURCES = badrw.c
|
|
From: Tom H. <th...@cy...> - 2004-11-16 19:44:08
|
CVS commit by thughes:
The calculation used to round the size of a new thread's stack to a
multiple of the page size had an off by one error. Fixed it to use
the PGROUNDUP macro instead of trying to do the calculation itself
and then get it wrong.
MERGE TO STABLE
A none/tests/pth_stackalign.c 1.1.2.1 [POSSIBLY UNSAFE: printf] [no copyright]
A none/tests/pth_stackalign.stderr.exp 1.1.2.1
A none/tests/pth_stackalign.stdout.exp 1.1.2.1
A none/tests/pth_stackalign.vgtest 1.1.2.1
M +1 -2 coregrind/vg_scheduler.c 1.171.2.3
M +1 -0 none/tests/.cvsignore 1.18.2.1
M +6 -2 none/tests/Makefile.am 1.43.2.1
--- valgrind/coregrind/vg_scheduler.c #1.171.2.2:1.171.2.3
@@ -1954,6 +1954,5 @@ void do__apply_in_new_thread ( ThreadId
/* Consider allocating the child a stack, if the one it already has
is inadequate. */
- new_stk_szb = si->size + VG_AR_CLIENT_STACKBASE_REDZONE_SZB + si->guardsize;
- new_stk_szb = (new_stk_szb + VKI_BYTES_PER_PAGE - 1) & ~VKI_BYTES_PER_PAGE;
+ new_stk_szb = PGROUNDUP(si->size + VG_AR_CLIENT_STACKBASE_REDZONE_SZB + si->guardsize);
VG_(threads)[tid].stack_guard_size = si->guardsize;
--- valgrind/none/tests/.cvsignore #1.18:1.18.2.1
@@ -40,4 +40,5 @@
pluto
pth_blockedsig
+pth_stackalign
rcl_assert
rcrl
--- valgrind/none/tests/Makefile.am #1.43:1.43.2.1
@@ -47,4 +47,6 @@
pth_blockedsig.stderr.exp \
pth_blockedsig.stdout.exp pth_blockedsig.vgtest \
+ pth_stackalign.stderr.exp \
+ pth_stackalign.stdout.exp pth_stackalign.vgtest \
pushpopseg.stderr.exp pushpopseg.stdout.exp pushpopseg.vgtest \
rcl_assert.stderr.exp rcl_assert.vgtest \
@@ -75,6 +77,6 @@
int munmap_exe map_unmap mq mremap rcl_assert rcrl readline1 \
resolv rlimit_nofile seg_override sem semlimit sha1_test \
- shortpush shorts smc1 susphello pth_blockedsig pushpopseg \
- syscall-restart1 syscall-restart2 system \
+ shortpush shorts smc1 susphello pth_blockedsig pth_stackalign \
+ pushpopseg syscall-restart1 syscall-restart2 system \
coolo_sigaction gxx304 yield
@@ -156,4 +158,6 @@
pth_blockedsig_SOURCES = pth_blockedsig.c
pth_blockedsig_LDADD = -lpthread
+pth_stackalign_SOURCES = pth_stackalign.c
+pth_stackalign_LDADD = -lpthread
# generic C++ ones
|