wasm-micro-runtime/tests/unit/exception-handling/CMakeLists.txt
Yi Liu 539bebed9c
Fix missing IS_INVALID_TAGINDEX check in RETHROW handler (#4837)
* Fix RETHROW handler missing IS_INVALID_TAGINDEX check

Add validation for exception_tag_index in the RETHROW opcode handler
to prevent out-of-bounds access to module->module->tags[] when the
tag index is INVALID_TAGINDEX (0xFFFFFFFF). This matches the existing
check in the THROW handler.

When CATCH_ALL catches a cross-module exception with an unknown tag,
it pushes INVALID_TAGINDEX onto the stack. Without this check, a
subsequent RETHROW would access tags[0xFFFFFFFF].

* Fix incorrect code section byte counts in exception handling test

The hand-crafted WASM binary in load_module_with_exception_handling had
an off-by-one in the code section: body size was declared as 7 but the
actual body (local count + try/catch_all/end/end) is only 6 bytes.
This caused the WASM loader to fail with "unexpected end" when it tried
to read past the available bytes.

Fix the body size from 7 to 6 and the code section size from 9 to 8.
2026-03-09 10:04:18 +08:00

41 lines
1.0 KiB
CMake

# Copyright (C) 2024 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.14)
project (test-exception-handling)
add_definitions (-DRUN_ON_LINUX)
add_definitions (-Dattr_container_malloc=malloc)
add_definitions (-Dattr_container_free=free)
set (WAMR_BUILD_AOT 0)
set (WAMR_BUILD_INTERP 1)
set (WAMR_BUILD_FAST_INTERP 0)
set (WAMR_BUILD_JIT 0)
set (WAMR_BUILD_LIBC_WASI 0)
set (WAMR_BUILD_APP_FRAMEWORK 0)
set (WAMR_BUILD_EXCE_HANDLING 1)
include (../unit_common.cmake)
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
include_directories (${IWASM_DIR}/interpreter)
file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
set (UNIT_SOURCE ${source_all})
set (unit_test_sources
${UNIT_SOURCE}
${WAMR_RUNTIME_LIB_SOURCE}
)
# Now simply link against gtest or gtest_main as needed. Eg
add_executable (exception_handling_test ${unit_test_sources})
target_link_libraries (exception_handling_test gtest_main)
gtest_discover_tests(exception_handling_test)