Fix two assertion fails in JIT found by Karl Skomski.

This commit is contained in:
Zoltán Herczeg 2015-08-24 09:25:04 +00:00
parent 9150629497
commit 67764372eb
6 changed files with 23 additions and 4 deletions

View File

@ -151,6 +151,9 @@ non-zero.
41. Improve first character match in JIT with SSE2 on x86. 41. Improve first character match in JIT with SSE2 on x86.
42. Fix two assertion fails in JIT. These issues were found by Karl Skomski
with a custom LLVM fuzzer.
Version 10.20 30-June-2015 Version 10.20 30-June-2015
-------------------------- --------------------------

View File

@ -5457,6 +5457,7 @@ sljit_uw typeoffset;
cc++; cc++;
ccbegin = cc; ccbegin = cc;
compares = 0; compares = 0;
if (cc[-1] & XCL_MAP) if (cc[-1] & XCL_MAP)
{ {
min = 0; min = 0;
@ -5596,9 +5597,10 @@ else if ((cc[-1] & XCL_MAP) != 0)
if (!check_class_ranges(common, (const sljit_ub *)cc, FALSE, TRUE, list)) if (!check_class_ranges(common, (const sljit_ub *)cc, FALSE, TRUE, list))
{ {
#if PCRE2_CODE_UNIT_WIDTH == 8 #if PCRE2_CODE_UNIT_WIDTH == 8
SLJIT_ASSERT(common->utf); jump = NULL;
if (common->utf)
#endif #endif
jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
@ -5607,7 +5609,10 @@ else if ((cc[-1] & XCL_MAP) != 0)
OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO)); add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));
JUMPHERE(jump); #if PCRE2_CODE_UNIT_WIDTH == 8
if (common->utf)
#endif
JUMPHERE(jump);
} }
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0); OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
@ -10657,7 +10662,7 @@ static SLJIT_INLINE void compile_recurse(compiler_common *common)
DEFINE_COMPILER; DEFINE_COMPILER;
PCRE2_SPTR cc = common->start + common->currententry->start; PCRE2_SPTR cc = common->start + common->currententry->start;
PCRE2_SPTR ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE); PCRE2_SPTR ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
PCRE2_SPTR ccend = bracketend(cc); PCRE2_SPTR ccend = bracketend(cc) - (1 + LINK_SIZE);
BOOL needs_control_head; BOOL needs_control_head;
int framesize = get_framesize(common, cc, NULL, TRUE, &needs_control_head); int framesize = get_framesize(common, cc, NULL, TRUE, &needs_control_head);
int private_data_size = get_private_data_copy_length(common, ccbegin, ccend, needs_control_head); int private_data_size = get_private_data_copy_length(common, ccbegin, ccend, needs_control_head);

View File

@ -247,4 +247,6 @@
/[^\xff]((?1))/BI /[^\xff]((?1))/BI
abcd abcd
/(x(?1)){4}/
# End of testinput17 # End of testinput17

3
testdata/testinput5 vendored
View File

@ -1659,4 +1659,7 @@
/\C(\W?ſ)'?{{/utf /\C(\W?ſ)'?{{/utf
\\C(\\W?ſ)'?{{ \\C(\\W?ſ)'?{{
/[\pS#moq]/
=
# End of testinput5 # End of testinput5

View File

@ -481,4 +481,6 @@ JIT compilation was successful
abcd abcd
Failed: error -46: JIT stack limit reached Failed: error -46: JIT stack limit reached
/(x(?1)){4}/
# End of testinput17 # End of testinput17

View File

@ -4060,4 +4060,8 @@ No match
\\C(\\W?ſ)'?{{ \\C(\\W?ſ)'?{{
No match No match
/[\pS#moq]/
=
0: =
# End of testinput5 # End of testinput5