Re: [pcre-dev] Internal errors and crashes with quantified s…

Top Page
Delete this message
Author: Graycode
Date:  
To: pcre-dev
Subject: Re: [pcre-dev] Internal errors and crashes with quantified subroutines
On Mon, 21 Nov 2011, Philip Hazel wrote:

> Thanks for supplying that; it shortened the time I needed to figure out
> what was going wrong (my failures were around 1999 as well).


You're quite welcome! Yesterday I was rummaging through the PCRE code
trying to determine where the underlying problem was. I tried lots of
changes but they generally just broke something and fixed nothing.
So I am very curious, but have not yet seen your resolution show up
in the on-line code repository at http://vcs.pcre.org/viewvc/code/

The portions of my previous post that you did Not quote provides hints
about how the problem may have been fixed. They indicate where I was
wrong (but you were too kind to say that).

I'm wondering if something like the following would address the issue.
I'll probably patch our 8.13 until we're ready to commit to a newer
version. The line numbers are based on the released 8.20 version.


***************
*** 4726,4737 ****
--- 4726,4739 ----
                uschar *this_hwm = cd->hwm;
                memcpy(code, previous, len);
                for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
                  {
                  PUT(cd->hwm, 0, GET(hc, 0) + len);
                  cd->hwm += LINK_SIZE;
+                 if (cd->hwm > cd->start_workspace + WORK_SIZE_CHECK)
+                   { *errorcodeptr = ERR52; goto FAILED; }
                  }
                save_hwm = this_hwm;
                code += len;
                }
              }
            }
***************
*** 4793,4804 ****
--- 4795,4808 ----


            memcpy(code, previous, len);
            for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
              {
              PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));
              cd->hwm += LINK_SIZE;
+             if (cd->hwm > cd->start_workspace + WORK_SIZE_CHECK)
+               { *errorcodeptr = ERR52; goto FAILED; }
              }
            save_hwm = this_hwm;
            code += len;
            }


          /* Now chain through the pending brackets, and fill in their length




Thanks,
Graycode