Philippe Waroquiers 275c1897dc Extensible main thread stack is tricky :(.
Revision 14976 causes a regression : stacktrace produced when the
stack has not yet been extended to cover SP will only contain one
element, as the stack limits are considered to be the limits of
the resvn segment.

This patch fixes that, by taking Resvn/SmUpper segment into
account to properly compute the limits.
It also contains a new regtest that fails with the trunk
(only one function in the stacktrace)
and succeeds with this patch (the 2 expected functions).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15046
2015-03-28 12:52:23 +00:00

24 lines
604 B
C

#include <stdio.h>
__attribute__((noinline)) void big(void)
{
/* The below ensures the stack grows a lot. However, we hope the stack
extension is not done yet, as no memory has been read/written. */
volatile char c[200000];
/* Access only the higher part of the stack, to avoid mapping SP */
/* The below 2 printfs should produce deterministic output, whatever
the random value of c[]. */
if (c[200000 - 1])
fprintf(stderr, "Accessing fresh %s\n", "stack");
else
fprintf(stderr, "Accessing %s stack\n", "fresh");
}
int main(void )
{
big();
return 0;
}