Add recursion limit for VM (#2737)

This patch adds posibility to supervise the VM call stack to avoid aborts/crashes due to the recursion calls.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-02-01 15:32:26 +01:00
committed by László Langó
parent 5c1a4f18ea
commit 6b9c924d08
7 changed files with 86 additions and 7 deletions
+7
View File
@@ -40,6 +40,7 @@ set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
set(FEATURE_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
set(REGEXP_RECURSION_LIMIT "0" CACHE STRING "Limit of regexp recursion depth")
set(VM_RECURSION_LIMIT "0" CACHE STRING "Limit of VM recursion depth")
# Option overrides
if(USING_MSVC)
@@ -96,6 +97,7 @@ message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
message(STATUS "FEATURE_VM_EXEC_STOP " ${FEATURE_VM_EXEC_STOP})
message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
message(STATUS "REGEXP_RECURSION_LIMIT " ${REGEXP_RECURSION_LIMIT})
message(STATUS "VM_RECURSION_LIMIT " ${VM_RECURSION_LIMIT})
# Include directories
set(INCLUDE_CORE_PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -235,6 +237,11 @@ if(REGEXP_RECURSION_LIMIT)
set(DEFINES_JERRY ${DEFINES_JERRY} REGEXP_RECURSION_LIMIT=${REGEXP_RECURSION_LIMIT})
endif()
# VM recursion depth limit
if(VM_RECURSION_LIMIT)
set(DEFINES_JERRY ${DEFINES_JERRY} VM_RECURSION_LIMIT=${VM_RECURSION_LIMIT})
endif()
# RegExp byte-code dumps
if(FEATURE_REGEXP_DUMP)
set(DEFINES_JERRY ${DEFINES_JERRY} REGEXP_DUMP_BYTE_CODE)