kamg@2589: #!/bin/sh kamg@2589: rdurbin@4802: # rdurbin@4802: # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. rdurbin@4802: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. rdurbin@4802: # rdurbin@4802: # This code is free software; you can redistribute it and/or modify it rdurbin@4802: # under the terms of the GNU General Public License version 2 only, as rdurbin@4802: # published by the Free Software Foundation. rdurbin@4802: # rdurbin@4802: # This code is distributed in the hope that it will be useful, but WITHOUT rdurbin@4802: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or rdurbin@4802: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License rdurbin@4802: # version 2 for more details (a copy is included in the LICENSE file that rdurbin@4802: # accompanied this code). rdurbin@4802: # rdurbin@4802: # You should have received a copy of the GNU General Public License version rdurbin@4802: # 2 along with this work; if not, write to the Free Software Foundation, rdurbin@4802: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. rdurbin@4802: # rdurbin@4802: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA rdurbin@4802: # or visit www.oracle.com if you need additional information or have any rdurbin@4802: # questions. rdurbin@4802: # rdurbin@4802: rdurbin@4802: rdurbin@4802: kamg@2589: ## kamg@2589: ## @test kamg@2589: ## @bug 6878713 rdurbin@4802: ## @bug 7030610 rdurbin@4802: ## @bug 7037122 rdurbin@4802: ## @bug 7123945 kamg@2589: ## @summary Verifier heap corruption, relating to backward jsrs rdurbin@4802: ## @run shell Test6878713.sh kamg@2589: ## collins@4831: ## some tests require path to find test source dir collins@4831: if [ "${TESTSRC}" = "" ] collins@4831: then collins@4831: TESTSRC=${PWD} collins@4831: echo "TESTSRC not set. Using "${TESTSRC}" as default" collins@4831: fi collins@4831: echo "TESTSRC=${TESTSRC}" collins@4831: ## Adding common setup Variables for running shell tests. collins@4831: . ${TESTSRC}/../../test_env.sh kamg@2589: rdurbin@4802: TARGET_CLASS=OOMCrashClass1960_2 kamg@2589: rdurbin@4802: echo "INFO: extracting the target class." collins@4832: ${COMPILEJAVA}${FS}bin${FS}jar xvf \ rdurbin@4802: ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class kamg@2589: rdurbin@4802: # remove any hs_err_pid that might exist here rdurbin@4802: rm -f hs_err_pid*.log rdurbin@4802: rdurbin@4802: echo "INFO: checking for 32-bit versus 64-bit VM." rdurbin@4802: ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \ rdurbin@4802: | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1 rdurbin@4802: status="$?" rdurbin@4802: if [ "$status" = 0 ]; then rdurbin@4802: echo "INFO: testing a 64-bit VM." rdurbin@4802: is_64_bit=true kamg@2589: else rdurbin@4802: echo "INFO: testing a 32-bit VM." kamg@2589: fi rdurbin@4802: rdurbin@4802: if [ "$is_64_bit" = true ]; then rdurbin@4802: # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296 rdurbin@4802: MALLOC_MAX=100663296 rdurbin@4802: else rdurbin@4802: # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592 rdurbin@4802: MALLOC_MAX=201326592 rdurbin@4802: fi rdurbin@4802: echo "INFO: MALLOC_MAX=$MALLOC_MAX" rdurbin@4802: rdurbin@4802: echo "INFO: executing the target class." rdurbin@4802: # -XX:+PrintCommandLineFlags for debugging purposes rdurbin@4802: # -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without rdurbin@4802: # the new -XX:MallocMaxTestWords option rdurbin@4802: # -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords rdurbin@4802: # -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX rdurbin@4802: ${TESTJAVA}${FS}bin${FS}java \ rdurbin@4802: -XX:+PrintCommandLineFlags \ rdurbin@4802: -XX:+IgnoreUnrecognizedVMOptions \ rdurbin@4802: -XX:+UnlockDiagnosticVMOptions \ rdurbin@4802: -XX:MallocMaxTestWords=$MALLOC_MAX \ rdurbin@4802: ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1 rdurbin@4802: rdurbin@4802: echo "INFO: begin contents of test.out:" rdurbin@4802: cat test.out rdurbin@4802: echo "INFO: end contents of test.out." rdurbin@4802: rdurbin@4802: echo "INFO: checking for memory allocation error message." rdurbin@4802: # We are looking for this specific memory allocation failure mesg so rdurbin@4802: # we know we exercised the right allocation path with the test class: rdurbin@4802: MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes" rdurbin@4802: grep "$MESG1" test.out rdurbin@4802: status="$?" rdurbin@4802: if [ "$status" = 0 ]; then rdurbin@4802: echo "INFO: found expected memory allocation error message." rdurbin@4802: else rdurbin@4802: echo "INFO: did not find expected memory allocation error message." rdurbin@4802: rdurbin@4802: # If we didn't find MESG1 above, then there are several scenarios: rdurbin@4802: # 1) -XX:MallocMaxTestWords is not supported by the current VM and we rdurbin@4802: # didn't fail TARGET_CLASS's memory allocation attempt; instead rdurbin@4802: # we failed to find TARGET_CLASS's main() method. The TARGET_CLASS rdurbin@4802: # is designed to provoke a memory allocation failure during class rdurbin@4802: # loading; we actually don't care about running the class which is rdurbin@4802: # why it doesn't have a main() method. rdurbin@4802: # 2) we failed a memory allocation, but not the one we were looking rdurbin@4802: # so it might be that TARGET_CLASS no longer tickles the same rdurbin@4802: # memory allocation code path rdurbin@4802: # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by rdurbin@4802: # 6878713 because the test is running on a pre-fix VM. rdurbin@4802: echo "INFO: checking for no main() method message." rdurbin@4802: MESG2="Error: Main method not found in class" rdurbin@4802: grep "$MESG2" test.out rdurbin@4802: status="$?" rdurbin@4802: if [ "$status" = 0 ]; then rdurbin@4802: echo "INFO: found no main() method message." rdurbin@4802: else rdurbin@4802: echo "FAIL: did not find no main() method message." rdurbin@4802: # status is non-zero for exit below rdurbin@4802: rdurbin@4802: if [ -s hs_err_pid*.log ]; then rdurbin@4802: echo "INFO: begin contents of hs_err_pid file:" rdurbin@4802: cat hs_err_pid*.log rdurbin@4802: echo "INFO: end contents of hs_err_pid file." rdurbin@4802: fi rdurbin@4802: fi rdurbin@4802: fi rdurbin@4802: rdurbin@4802: if [ "$status" = 0 ]; then rdurbin@4802: echo "PASS: test found one of the expected messages." rdurbin@4802: fi rdurbin@4802: exit "$status"