Author: florian
Date: Sat May 9 23:14:43 2015
New Revision: 15197
Log:
Make the return value of VG_(am_extend_client_stack) consistent with
VG_(am_resize_client_dataseg).
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/ASPACEM_TWEAKS/coregrind/m_signals.c
branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h
branches/ASPACEM_TWEAKS/none/tests/linux/stack-overflow.stderr.exp
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Sat May 9 23:14:43 2015
@@ -3066,16 +3066,14 @@
/* Extend the client stack such that ADDR is mapped. Unless ADDR is already
- mapped in which case nothing happens. If the function fails, it returns
- an error and provides the address to which the stack should have been
- extended. OVERFLOW indicates whether this failure was due to an overflow
- or some other cause. */
-SysRes VG_(am_extend_client_stack) ( Addr addr, Bool *overflow )
+ mapped in which case nothing happens. Return an error if the stack could
+ not be extended. A +1 error code means "overflow" and 0 means some other
+ failure. */
+SysRes VG_(am_extend_client_stack) ( Addr addr, Addr *new_stack_base )
{
SizeT udelta;
SysRes sres = VG_(mk_SysRes_Success)(0);
-
- *overflow = False;
+ Bool overflow = False;
/* Get the segment containing addr. */
const NSegment *seg = VG_(am_find_nsegment)(addr);
@@ -3085,22 +3083,27 @@
because although it tests whether the segment is mapped
_somehow_, it doesn't check that it has the right permissions
(r,w, maybe x) ? */
- if (seg->kind == SkAnonC)
+ if (seg->kind == SkAnonC) {
/* ADDR is already mapped. Nothing to do. */
+ *new_stack_base = seg->start; // not really "new" :)
return sres;
+ }
const NSegment *anon_seg = VG_(am_next_nsegment)(seg, True/*fwds*/);
vg_assert(anon_seg != NULL);
udelta = VG_PGROUNDUP(anon_seg->start - addr);
+ *new_stack_base = anon_seg->start - udelta;
VG_(debugLog)(1, "signals",
"extending a stack base 0x%lx down by %lu\n",
anon_seg->start, udelta);
if (! VG_(am_extend_into_adjacent_reservation_client)
- ( anon_seg->start, -(SSizeT)udelta, overflow )) {
- Addr new_stack_base = anon_seg->start - udelta;
- sres = VG_(mk_SysRes_Error)(new_stack_base);
+ ( anon_seg->start, -(SSizeT)udelta, &overflow )) {
+ if (overflow)
+ sres = VG_(mk_SysRes_Error)(1);
+ else
+ sres = VG_(mk_SysRes_Error)(0);
}
return sres;
}
Modified: branches/ASPACEM_TWEAKS/coregrind/m_signals.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_signals.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_signals.c Sat May 9 23:14:43 2015
@@ -2275,15 +2275,16 @@
*/
Bool VG_(extend_stack)(ThreadId tid, Addr addr)
{
- Bool overflow;
- SysRes sres = VG_(am_extend_client_stack)(addr, &overflow);
+ Addr new_stack_base;
+ SysRes sres = VG_(am_extend_client_stack)(addr, &new_stack_base);
if (sr_isError(sres)) {
- Addr new_stack_base = sr_Err(sres);
- if (overflow)
+ if (sr_Err(sres) == 1) {
VG_(umsg)("Stack overflow in thread #%d: can't grow stack to %#lx\n",
tid, new_stack_base);
- else
+ VG_(umsg)("Increasing the size of the main thread stack with "
+ "--main-stacksize=<number> might help\n");
+ } else
VG_(umsg)("Cannot map memory to grow the stack for thread #%d "
"to %#lx\n", tid, new_stack_base);
return False;
Modified: branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h (original)
+++ branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h Sat May 9 23:14:43 2015
@@ -316,7 +316,7 @@
extern SysRes VG_(am_alloc_extensible_client_stack) ( Addr stack_end,
SizeT max_size,
UInt prot );
-extern SysRes VG_(am_extend_client_stack) ( Addr addr, Bool *overflow );
+extern SysRes VG_(am_extend_client_stack) ( Addr addr, Addr *new_stack_base );
//--------------------------------------------------------------
// Valgrind (non-client) thread stacks. V itself runs on such
Modified: branches/ASPACEM_TWEAKS/none/tests/linux/stack-overflow.stderr.exp
==============================================================================
--- branches/ASPACEM_TWEAKS/none/tests/linux/stack-overflow.stderr.exp (original)
+++ branches/ASPACEM_TWEAKS/none/tests/linux/stack-overflow.stderr.exp Sat May 9 23:14:43 2015
@@ -1,9 +1,11 @@
Stack overflow in thread #1: can't grow stack to 0x........
+Increasing the size of the main thread stack with --main-stacksize=<number> might help
Process terminating with default action of signal 11 (SIGSEGV)
Access not within mapped region at address 0x........
Stack overflow in thread #1: can't grow stack to 0x........
+Increasing the size of the main thread stack with --main-stacksize=<number> might help
at 0x........: main (stack-overflow.c:5)
If you believe this happened as a result of a stack
overflow in your program's main thread (unlikely but
|