#!/bin/sh ## ## @test TooSmallStackSize.sh ## @bug 6762191 ## @summary Setting stack size to 16K causes segmentation fault ## @run shell TooSmallStackSize.sh ## ## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then TESTSRC=${PWD} echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" ## Adding common setup Variables for running shell tests. . ${TESTSRC}/../../test_env.sh JAVA=${TESTJAVA}${FS}bin${FS}java # Current directory is scratch directory, copy all the test source there # (for the subsequent moves to work). ${CP} ${TESTSRC}${FS}/TooSmallStackSize.sh ${THIS_DIR} # Run java with 16k stack size, which caused a crash on some platforms ${JAVA} ${TESTOPTS} -Xss16k -version >test.out 2>&1 result=$? cat test.out # The result of a 16k stack size should be a quick exit with a complaint # that the stack size is too small. However, for some win32 builds, the # stack is always at least 64k, and this also sometimes is the minimum # allowed size, so we won't see an error in this case. if [ "$result" != "0" ]; then grep "The stack size specified is too small" test.out if [ "$?" != "0" ]; then printf "FAILED #1: Did not get expected error message with stack size of 16k\n" exit 1 fi printf "PASSED #1: got expected error message with stack size of 16k\n" else printf "PASSED #1: got no error message with stack size of 16k\n" fi # Now try again with a 32k stack size, which is the size that the launcher will # set to if you try setting to anything smaller. This should produce the same # result as setting to 16k. ${JAVA} ${TESTOPTS} -Xss32k -version >test.out 2>&1 result=$? cat test.out # The result of a 32k stack size should again be a quick exit with a complaint # that the stack size is too small. Once again, this might not fail on win32. if [ "$result" != "0" ]; then grep "The stack size specified is too small" test.out if [ "$?" != "0" ]; then printf "FAILED #2: Did not get expected error message with stack size of 32k\n" exit 1 fi printf "PASSED #2: got expected error message with stack size of 32k\n" # Error message contains the minimum stack size allowed. min_stack_allowed=`grep Specify.at.least test.out | sed -e 's/.*Specify at least \(.*k\).*/\1/g'` else printf "PASSED #2: got no error message with stack size of 32k\n" # No error message, so just use the same size again on the next run. min_stack_allowed="32k" fi # Try again with a the minimum stack size that was given in the error message ${JAVA} ${TESTOPTS} -Xss${min_stack_allowed} -version >test.out 2>&1 result=$? cat test.out # The result should be success running java -version. if [ "$result" != "0" ]; then printf "FAILED #3: VM failed to launch with minimum allowed stack size of %dk\n" $min_stack_allowed exit 1 else printf "PASSED #3: VM launched with minimum allowed stack size of %dk\n" $min_stack_allowed fi printf "PASSED.\n"