Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solaris 11/x86: wrong STACKBOTTOM #122

Closed
wangp opened this issue Jun 15, 2016 · 3 comments
Closed

Solaris 11/x86: wrong STACKBOTTOM #122

wangp opened this issue Jun 15, 2016 · 3 comments

Comments

@wangp
Copy link
Contributor

wangp commented Jun 15, 2016

Hi, it appears the determination of STACKBOTTOM does not work on Solaris 11/x86.

I tested with the latest 'master' branch. Note that I disable threads. make check passes when threads are enabled.

# uname -a
SunOS solaris 5.11 11.2 i86pc i386 i86pc

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/lto-wrapper
Target: i386-pc-solaris2.11
Configured with: /builds/hudson/workspace/nightly-update/build/i386/components/gcc48/gcc-4.8.2/configure CC=/usr/gcc/4.7/bin/gcc CXX=/usr/gcc/4.7/bin/g++ --prefix=/usr/gcc/4.8 --mandir=/usr/gcc/4.8/share/man --bindir=/usr/gcc/4.8/bin --libdir=/usr/gcc/4.8/lib --sbindir=/usr/gcc/4.8/sbin --infodir=/usr/gcc/4.8/share/info --libexecdir=/usr/gcc/4.8/lib --enable-languages=c,c++,fortran,objc --enable-shared --with-gmp-include=/usr/include/gmp --with-mpfr-include=/usr/include/mpfr --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/usr/gnu/bin/as CFLAGS='-g -O2  -mtune=opteron -march=opteron' CXXFLAGS='-g -O2 -mtune=opteron -march=opteron'
Thread model: posix
gcc version 4.8.2 (GCC) 

# autoreconf -vif
# automake --add-missing
# ./configure --disable-threads
# gmake -j4
# gmake check
...
gmake  check-TESTS
gmake[2]: Entering directory `/root/bdwgc'
/bin/sh: line 10: 10801: Memory fault(coredump)
FAIL: cordtest
Switched to incremental mode
Emulating dirty bits with mprotect/signals
/bin/sh: line 10: 10810: Memory fault(coredump)
FAIL: gctest
/bin/sh: line 10: 10819: Memory fault(coredump)
FAIL: leaktest
/bin/sh: line 10: 10828: Memory fault(coredump)
FAIL: middletest
/bin/sh: line 10: 10837: Memory fault(coredump)
FAIL: smashtest
/bin/sh: line 10: 10846: Memory fault(coredump)
FAIL: hugetest
/bin/sh: line 10: 10855: Memory fault(coredump)
FAIL: realloc_test
/bin/sh: line 10: 10864: Memory fault(coredump)
FAIL: staticrootstest
/bin/sh: line 10: 10873: Memory fault(coredump)
FAIL: disclaim_test
/bin/sh: line 10: 10882: Memory fault(coredump)
FAIL: disclaim_bench
==========================================
10 of 10 tests failed
Please report to [email protected]
==========================================

It seems STACKBOTTOM is wrong. make check passes after applying this hack (in the #ifdef I386 block):

diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index f4935b4..a287b4b 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -1265,7 +1265,8 @@
 /*      old executables.                                                */
 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
 #       include <sys/vm.h>
-#       define STACKBOTTOM ((ptr_t)USRSTACK)
+//#       define STACKBOTTOM ((ptr_t)USRSTACK)
+#      define HEURISTIC2
 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
 /* It appears to be fixed in 2.8 and 2.9.                               */
 #       ifdef SOLARIS25_PROC_VDB_BUG_FIXED

Perhaps the I386 block requires the same code as for X86_64 and SPARC? i.e. this stuff

/*      # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,      */                                             
/*      but reportedly breaks under 2.8.  It appears that the stack     */                                             
/*      base is a property of the executable, so this should not break  */                                             
/*      old executables.                                                */                                             
/*      HEURISTIC2 probably works, but this appears to be preferable.   */                                             
/*      Apparently USRSTACK is defined to be USERLIMIT, but in some     */                                             
/*      installations that's undefined.  We work around this with a     */                                             
/*      gross hack:                                                     */                                             
#       include <sys/vmparam.h>
#       ifdef USERLIMIT
          /* This should work everywhere, but doesn't.  */                                                             
#         define STACKBOTTOM ((ptr_t)USRSTACK)                                                                         
#       else
#         define HEURISTIC2                                                                                            
#       endif
@wangp
Copy link
Contributor Author

wangp commented Jun 16, 2016

I've tested the HEURISTIC2 change on a bigger test case, the Mercury compiler. With the change, it works as expected.

@ivmai
Copy link
Owner

ivmai commented Jun 16, 2016

The fix merged to master - 81cae56
Please check.

@ivmai ivmai closed this as completed Jun 16, 2016
@wangp
Copy link
Contributor Author

wangp commented Jun 17, 2016

Thanks, Ivan. It looks fine.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Nov 10, 2016
USERLIMIT is given.

From Brad Forschinger in PR pkg/49787

Also from both boehm-gc commit, where there is a longer description of issues
in issue #122:
ivmai/bdwgc#122
ivmai/bdwgc@81cae56

we have the additions here (adding the definition of STACKBOTTOM if USERLIMIT
otherwise use HEURISTIC2), but not the removal of the first part, which
declares STACKBOTTOM unconditionally.

Reportedly fixes build on SunOS 5.10 sun4u.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants