Pierre Joye wrote:

> On Jul 23, 2015 9:47 PM, "Christoph Becker" <cmbecke...@gmx.de> wrote:
>>
>> Ah, I should have explained better that libpcre's JIT support is
>> implemented as own virtual machine, and libpcre has functions to use a
>> custom stack which is allocated on the heap.  If these functions are not
>> used (as it's now in ext/pcre) a fixed 32K on the machine stack are
> used.[1]
>>
>> Anyhow, it is not possible to change the stack (size) during a call to
>> pcre_exec() (unless, maybe, libpcre would be modified), and it is not
>> possible (to my knowledge) to calculate the required stack size in
>> advance.  The required stack size depends on pattern and subject.
>>
>> So basically, we have to call pcre_exec(), and if it fails due to
>> limited stack size, we either fail as well, or we try again.  In the
>> latter case we could either use a bigger stack or do without JIT.  In
>> the former case we should at least give users a setting to choose the
>> desired stack size, which is quite comparable to pcre.backtrack_limit
>> and pcre.recursion_limit.
>>
>> Therefore I tend to prefer a new ini setting (say, pcre.jitstack_limit).
>>  That would mean, however, to add yet another ini setting, of which
>> there are already so many.
>>
>> [1] <http://www.pcre.org/original/doc/html/pcrejit.html#SEC8>
> 
> Only to be sure, ou mean it is a different issue than the common one (dozen
> of bugs for pcre about it)? Solved by increasing the stack size of the
> process or binary?

I'm pretty sure that is another issue.  The JIT functionality of libpcre
is available only for PHP 7, and the issue reported in #70110 only
happens when pcre.jit is enabled.  And to my knowledge #70110 is the
first reported bug that's caused by the JIT.

> Also an ini setting may not be portable. That's something to double check :)

ACK.  However, AFAICT pcre_jit_stack_alloc() and pcre_assign_jit_stack()
are supposed to be portable for systems where JIT support is available.

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to