haikuwebkit/LayoutTests/js/stack-overflow-regexp.html

11 lines
260 B
HTML
Raw Permalink Normal View History

[JSC] RegExp with deeply nested subexpressions overflow the stack in Yarr https://bugs.webkit.org/show_bug.cgi?id=158011 rdar://problem/25946592 Reviewed by Saam Barati. Source/JavaScriptCore: When generating the meta-data required for compilation, Yarr uses a recursive function over the various expression in the pattern. If you have many nested expressions, you can run out of stack and crash the WebProcess. This patch changes that into a soft failure. The expression is just considered invalid. * runtime/RegExp.cpp: (JSC::RegExp::finishCreation): (JSC::RegExp::compile): (JSC::RegExp::compileMatchOnly): * yarr/YarrPattern.cpp: (JSC::Yarr::YarrPatternConstructor::YarrPatternConstructor): (JSC::Yarr::YarrPatternConstructor::setupOffsets): (JSC::Yarr::YarrPatternConstructor::isSafeToRecurse): (JSC::Yarr::YarrPattern::compile): (JSC::Yarr::YarrPattern::YarrPattern): (JSC::Yarr::YarrPatternConstructor::setupAlternativeOffsets): Deleted. (JSC::Yarr::YarrPatternConstructor::setupDisjunctionOffsets): Deleted. * yarr/YarrPattern.h: LayoutTests: * js/script-tests/stack-overflow-arrity-catch.js: With the new failure, this test can fail on allocating the RegExp for a valid reason. The new expression should not have this issue. * js/script-tests/stack-overflow-regexp.js: Added. (shouldThrow.recursiveCall): (shouldThrow): (recursiveCall): * js/stack-overflow-regexp-expected.txt: Added. * js/stack-overflow-regexp.html: Added. Canonical link: https://commits.webkit.org/176215@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-26 03:19:06 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/stack-overflow-regexp.js "></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>