|
From: <sv...@va...> - 2012-09-02 21:19:38
|
sewardj 2012-09-02 22:19:29 +0100 (Sun, 02 Sep 2012)
New Revision: 12948
Log:
Merge from trunk, r12947 (Fix stack bounds check, n-i-bz)
Modified directories:
branches/VALGRIND_3_8_BRANCH/
branches/VALGRIND_3_8_BRANCH/coregrind/
branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/
Modified files:
branches/VALGRIND_3_8_BRANCH/coregrind/m_main.c
branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/syswrap-generic.c
Modified: branches/VALGRIND_3_8_BRANCH/
Modified: branches/VALGRIND_3_8_BRANCH/coregrind/
Modified: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/
Property changed: branches/VALGRIND_3_8_BRANCH (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN:12477-12516
/trunk:12873,12878-12879,12885,12887,12891-12894,12897-12898,12923
+ /branches/TCHAIN:12477-12516
/trunk:12873,12878-12879,12885,12887,12891-12894,12897-12898,12923,12947
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/syswrap-generic.c (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind/m_syswrap/syswrap-generic.c:12477-12516
/trunk/coregrind/m_syswrap/syswrap-generic.c:12874,12878-12879,12881-12883,12885,12887,12891-12894,12897-12898,12923
+ /branches/TCHAIN/coregrind/m_syswrap/syswrap-generic.c:12477-12516
/trunk/coregrind/m_syswrap/syswrap-generic.c:12874,12878-12879,12881-12883,12885,12887,12891-12894,12897-12898,12923,12947
Modified: branches/VALGRIND_3_8_BRANCH/coregrind/m_main.c (+18 -6)
===================================================================
--- branches/VALGRIND_3_8_BRANCH/coregrind/m_main.c 2012-09-02 22:17:36 +01:00 (rev 12947)
+++ branches/VALGRIND_3_8_BRANCH/coregrind/m_main.c 2012-09-02 22:19:29 +01:00 (rev 12948)
@@ -1613,12 +1613,24 @@
VG_(debugLog)(1, "main", "Checking current stack is plausible\n");
{ HChar* limLo = (HChar*)(&VG_(interim_stack).bytes[0]);
HChar* limHi = limLo + sizeof(VG_(interim_stack));
- HChar* aLocal = (HChar*)&limLo; /* any auto local will do */
- /* "Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on
- LLVM 3.1svn)" appears to miscompile the following check,
- causing run to abort at this point (in 64-bit mode) even
- though aLocal is within limLo .. limHi. Try building with
- gcc instead. */
+ HChar* volatile
+ aLocal = (HChar*)&limLo; /* any auto local will do */
+ /* Re "volatile": Apple clang version 4.0
+ (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)" appeared
+ to miscompile the following check, causing run to abort at
+ this point (in 64-bit mode) even though aLocal is within limLo
+ .. limHi. But in fact clang is within its rights to do
+ strange things here. "The reason is that the comparisons
+ aLocal < limLo and aLocal >= limHi cause undefined behaviour
+ (according to c99 6.5.8) because they compare pointers that do
+ not point into the same aggregate." Adding "volatile" appears
+ to fix it because "The compiler would have to prove that there
+ is undefined behavior in order to exploit it. But as a
+ volatile variable can change its value in ways invisible to
+ the compiler, the compiler must make the conservative
+ assumption that it points into the same aggregate as the other
+ pointer its compared against. I.e. the behaviour is possibly
+ defined." (Analysis by Florian Krohm). */
if (aLocal < limLo || aLocal >= limHi) {
/* something's wrong. Stop. */
VG_(debugLog)(0, "main", "Root stack %p to %p, a local %p\n",
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind:12477-12516
/trunk/coregrind:12873,12881,12885,12887,12891-12894,12897-12898,12923
+ /branches/TCHAIN/coregrind:12477-12516
/trunk/coregrind:12873,12881,12885,12887,12891-12894,12897-12898,12923,12947
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind/m_syswrap:12477-12516
/trunk/coregrind/m_syswrap:12873,12881-12883,12885,12887,12891-12894,12897-12898,12923
+ /branches/TCHAIN/coregrind/m_syswrap:12477-12516
/trunk/coregrind/m_syswrap:12873,12881-12883,12885,12887,12891-12894,12897-12898,12923,12947
|