mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00

This is a test code to examine native stack overflow detection logic. The current output on my environment (macOS amd64): ```shell ====== Interpreter stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 14704 | failed | leaked | Exception: native stack overflow 14704 - 17904 | failed | ok | Exception: native stack overflow 17904 - 24576 | ok | ok | ====== AOT stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 18176 | failed | leaked | Exception: native stack overflow 18176 - 24576 | ok | ok | ====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 1968 | failed | ok | Exception: native stack overflow 1968 - 24576 | ok | ok | ``` This is a preparation to work on relevant issues, including: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325 https://github.com/bytecodealliance/wasm-micro-runtime/issues/3320 https://github.com/bytecodealliance/wasm-micro-runtime/issues/3314 https://github.com/bytecodealliance/wasm-micro-runtime/issues/3297
76 lines
1.8 KiB
Bash
Executable File
76 lines
1.8 KiB
Bash
Executable File
#
|
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
#
|
|
|
|
#!/bin/bash
|
|
|
|
CURR_DIR=$PWD
|
|
WAMR_DIR=${PWD}/../..
|
|
OUT_DIR=${PWD}/out
|
|
|
|
WASM_APPS=${PWD}/wasm-apps
|
|
|
|
|
|
rm -rf ${OUT_DIR}
|
|
mkdir ${OUT_DIR}
|
|
mkdir ${OUT_DIR}/wasm-apps
|
|
|
|
|
|
echo "##################### build (default)"
|
|
cd ${CURR_DIR}
|
|
mkdir -p cmake_build
|
|
cd cmake_build
|
|
cmake ..
|
|
make -j 4
|
|
if [ $? != 0 ];then
|
|
echo "BUILD_FAIL native-stack-overflow exit as $?\n"
|
|
exit 2
|
|
fi
|
|
cp -a native-stack-overflow ${OUT_DIR}
|
|
|
|
echo "##################### build (WAMR_DISABLE_HW_BOUND_CHECK=1)"
|
|
cd ${CURR_DIR}
|
|
mkdir -p cmake_build_disable_hw_bound
|
|
cd cmake_build_disable_hw_bound
|
|
cmake -D WAMR_DISABLE_HW_BOUND_CHECK=1 ..
|
|
make -j 4
|
|
if [ $? != 0 ];then
|
|
echo "BUILD_FAIL native-stack-overflow exit as $?\n"
|
|
exit 2
|
|
fi
|
|
cp -a native-stack-overflow ${OUT_DIR}/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK
|
|
|
|
echo
|
|
|
|
echo "##################### build wasm apps"
|
|
|
|
cd ${WASM_APPS}
|
|
|
|
for i in `ls *.c`
|
|
do
|
|
APP_SRC="$i"
|
|
OUT_FILE=${i%.*}.wasm
|
|
|
|
# use WAMR SDK to build out the .wasm binary
|
|
/opt/wasi-sdk/bin/clang \
|
|
-mexec-model=reactor \
|
|
-Os -z stack-size=4096 -Wl,--initial-memory=65536 \
|
|
-Wl,--allow-undefined \
|
|
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
|
|
|
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
|
echo "build ${OUT_FILE} success"
|
|
else
|
|
echo "build ${OUT_FILE} fail"
|
|
fi
|
|
done
|
|
echo "#################### build wasm apps done"
|
|
|
|
echo "#################### aot-compile"
|
|
WAMRC=${WAMR_DIR}/wamr-compiler/build/wamrc
|
|
${WAMRC} -o ${OUT_DIR}/wasm-apps/${OUT_FILE}.aot ${OUT_DIR}/wasm-apps/${OUT_FILE}
|
|
|
|
echo "#################### aot-compile (--bounds-checks=1)"
|
|
${WAMRC} -o ${OUT_DIR}/wasm-apps/${OUT_FILE}.aot.bounds-checks --bounds-checks=1 ${OUT_DIR}/wasm-apps/${OUT_FILE}
|