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:
committed by
László Langó
parent
5c1a4f18ea
commit
6b9c924d08
@@ -128,6 +128,8 @@ def get_arguments():
|
||||
help=devhelp('enable regexp strict mode (%(choices)s)'))
|
||||
coregrp.add_argument('--regexp-recursion-limit', metavar='N', type=int,
|
||||
help='regexp recursion depth limit')
|
||||
coregrp.add_argument('--vm-recursion-limit', metavar='N', type=int,
|
||||
help='VM recursion depth limit')
|
||||
coregrp.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
help=devhelp('enable parser byte-code dumps (%(choices)s)'))
|
||||
coregrp.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
@@ -152,6 +154,11 @@ def get_arguments():
|
||||
parser.print_help()
|
||||
sys.exit(0)
|
||||
|
||||
if arguments.vm_recursion_limit:
|
||||
if arguments.vm_recursion_limit < 0:
|
||||
print ('Configuration error: VM recursion limit must be greater or equal than 0')
|
||||
sys.exit(1)
|
||||
|
||||
return arguments
|
||||
|
||||
def generate_build_options(arguments):
|
||||
@@ -197,6 +204,7 @@ def generate_build_options(arguments):
|
||||
build_options_append('FEATURE_PROFILE', arguments.profile)
|
||||
build_options_append('FEATURE_REGEXP_STRICT_MODE', arguments.regexp_strict_mode)
|
||||
build_options_append('REGEXP_RECURSION_LIMIT', arguments.regexp_recursion_limit)
|
||||
build_options_append('VM_RECURSION_LIMIT', arguments.vm_recursion_limit)
|
||||
build_options_append('FEATURE_PARSER_DUMP', arguments.show_opcodes)
|
||||
build_options_append('FEATURE_REGEXP_DUMP', arguments.show_regexp_opcodes)
|
||||
build_options_append('FEATURE_SNAPSHOT_EXEC', arguments.snapshot_exec)
|
||||
|
||||
+11
-7
@@ -36,6 +36,7 @@ def skip_if(condition, desc):
|
||||
OPTIONS_PROFILE_MIN = ['--profile=minimal']
|
||||
OPTIONS_PROFILE_ES51 = [] # NOTE: same as ['--profile=es5.1']
|
||||
OPTIONS_PROFILE_ES2015 = ['--profile=es2015-subset']
|
||||
OPTIONS_VM_RECURSION_LIMIT = ['--vm-recursion-limit=1000']
|
||||
OPTIONS_DEBUG = ['--debug']
|
||||
OPTIONS_SNAPSHOT = ['--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on']
|
||||
OPTIONS_UNITTESTS = ['--unittests=on', '--jerry-cmdline=off', '--error-messages=on',
|
||||
@@ -67,21 +68,22 @@ JERRY_UNITTESTS_OPTIONS = [
|
||||
# Test options for jerry-tests
|
||||
JERRY_TESTS_OPTIONS = [
|
||||
Options('jerry_tests-es5.1',
|
||||
OPTIONS_PROFILE_ES51),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_VM_RECURSION_LIMIT),
|
||||
Options('jerry_tests-es5.1-snapshot',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT,
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_VM_RECURSION_LIMIT,
|
||||
['--snapshot']),
|
||||
Options('jerry_tests-es5.1-debug',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_VM_RECURSION_LIMIT),
|
||||
Options('jerry_tests-es5.1-debug-snapshot',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_DEBUG,
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_DEBUG + OPTIONS_VM_RECURSION_LIMIT,
|
||||
['--snapshot']),
|
||||
Options('jerry_tests-es5.1-debug-cpointer_32bit',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + ['--cpointer-32bit=on', '--mem-heap=1024']),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_VM_RECURSION_LIMIT
|
||||
+ ['--cpointer-32bit=on', '--mem-heap=1024']),
|
||||
Options('jerry_tests-es5.1-debug-external_context',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + ['--external-context=on']),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_VM_RECURSION_LIMIT + ['--external-context=on']),
|
||||
Options('jerry_tests-es2015_subset-debug',
|
||||
OPTIONS_PROFILE_ES2015 + OPTIONS_DEBUG),
|
||||
OPTIONS_PROFILE_ES2015 + OPTIONS_DEBUG + OPTIONS_VM_RECURSION_LIMIT),
|
||||
]
|
||||
|
||||
# Test options for jerry-test-suite
|
||||
@@ -156,6 +158,8 @@ JERRY_BUILDOPTIONS = [
|
||||
['--jerry-cmdline-snapshot=on']),
|
||||
Options('buildoption_test-regexp_recursion_limit',
|
||||
['--regexp-recursion-limit=1000']),
|
||||
Options('buildoption_test-vm_recursion_limit',
|
||||
OPTIONS_VM_RECURSION_LIMIT),
|
||||
]
|
||||
|
||||
def get_arguments():
|
||||
|
||||
Reference in New Issue
Block a user