[Pcre-svn] [344] code/trunk: The JIT compiler should restore…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [344] code/trunk: The JIT compiler should restore the control chain for empty possessive repeats.
Revision: 344
          http://www.exim.org/viewvc/pcre2?view=rev&revision=344
Author:   zherczeg
Date:     2015-08-11 14:20:37 +0100 (Tue, 11 Aug 2015)
Log Message:
-----------
The JIT compiler should restore the control chain for empty possessive repeats.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_jit_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-08-11 05:30:10 UTC (rev 343)
+++ code/trunk/ChangeLog    2015-08-11 13:20:37 UTC (rev 344)
@@ -136,7 +136,10 @@
 36. The JIT compiler should not check repeats after a {0,1} repeat byte code.
 This issue was found by Karl Skomski with a custom LLVM fuzzer.


+37. The JIT compiler should restore the control chain for empty possessive
+repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.

+
Version 10.20 30-June-2015
--------------------------


Modified: code/trunk/src/pcre2_jit_compile.c
===================================================================
--- code/trunk/src/pcre2_jit_compile.c    2015-08-11 05:30:10 UTC (rev 343)
+++ code/trunk/src/pcre2_jit_compile.c    2015-08-11 13:20:37 UTC (rev 344)
@@ -8055,6 +8055,10 @@
       OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
       }


+    /* Even if the match is empty, we need to reset the control head. */
+    if (needs_control_head)
+      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
+
     if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
       add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));


@@ -8082,6 +8086,10 @@
       OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
       }


+    /* Even if the match is empty, we need to reset the control head. */
+    if (needs_control_head)
+      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
+
     if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
       add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));


@@ -8094,9 +8102,6 @@
       }
     }


-  if (needs_control_head)
-    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
-
   JUMPTO(SLJIT_JUMP, loop);
   flush_stubs(common);



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-08-11 05:30:10 UTC (rev 343)
+++ code/trunk/testdata/testinput2    2015-08-11 13:20:37 UTC (rev 344)
@@ -4404,5 +4404,11 @@
 /(*CRLF)(*LIMIT_MATCH=)abc/


 /(?:ab)?(?:ab)(?:ab)/
+    abab
+    ababab
+    aba


+/((*MARK:A))++a(*SKIP:B)b/
+    aacb
+
 # End of testinput2 


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-08-11 05:30:10 UTC (rev 343)
+++ code/trunk/testdata/testoutput2    2015-08-11 13:20:37 UTC (rev 344)
@@ -14658,5 +14658,15 @@
 Failed: error 160 at offset 21: (*VERB) not recognized or malformed


 /(?:ab)?(?:ab)(?:ab)/
+    abab
+ 0: abab
+    ababab
+ 0: ababab
+    aba
+No match


+/((*MARK:A))++a(*SKIP:B)b/
+    aacb
+No match
+
 # End of testinput2