[Pcre-svn] [1592] code/trunk: The JIT compiler should restor…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1592] code/trunk: The JIT compiler should restore the control chain for empty possessive repeats.
Revision: 1592
          http://vcs.pcre.org/viewvc?view=rev&revision=1592
Author:   zherczeg
Date:     2015-08-11 14:34:44 +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/pcre_jit_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-08-11 05:41:09 UTC (rev 1591)
+++ code/trunk/ChangeLog    2015-08-11 13:34:44 UTC (rev 1592)
@@ -129,7 +129,10 @@
 33. 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.


+34. 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 8.37 28-April-2015
--------------------------


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2015-08-11 05:41:09 UTC (rev 1591)
+++ code/trunk/pcre_jit_compile.c    2015-08-11 13:34:44 UTC (rev 1592)
@@ -2243,6 +2243,7 @@
     SLJIT_ASSERT_STOP();
     break;
     }
+  SLJIT_ASSERT(current > (sljit_sw*)current[-1]);
   current = (sljit_sw*)current[-1];
   }
 return -1;
@@ -7695,6 +7696,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));


@@ -7722,6 +7727,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));


@@ -7734,9 +7743,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:41:09 UTC (rev 1591)
+++ code/trunk/testdata/testinput2    2015-08-11 13:34:44 UTC (rev 1592)
@@ -4204,5 +4204,11 @@
 /(?(8000000000/


 /(?: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:41:09 UTC (rev 1591)
+++ code/trunk/testdata/testoutput2    2015-08-11 13:34:44 UTC (rev 1592)
@@ -14550,5 +14550,15 @@
 Failed: number is too big at offset 13


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


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