Re: Recovering from a hung regex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On May 25, 2020 1:41:35 PM UTC, Shivanand Sharma <shivanand@xxxxxxxxxxxxxx> wrote:
>Hi,
>
>Thanks. Yes I've tested it and there's also a link to github. The
>script is
>a poc script to demonstrate the issue. However php may beb running an
>as
>apache module or as cgi implementation depending on the target
>environment.
>This means we have little say in availability of workers.
>
>On Mon, 25 May 2020, 1:21 pm Ashley Sheridan,
><ash@xxxxxxxxxxxxxxxxxxxx>
>wrote:
>
>>
>>
>> On May 24, 2020 3:23:23 PM UTC, Shivanand Sharma
><shivanand@xxxxxxxxxxxxxx>
>> wrote:
>> >Hi,
>> >
>> >We have a file scanner where data / files is user-supplied and the
>> >regexes
>> >are OSINT supplied. The script has no control over either and just
>> >needs to
>> >do its job successfully.
>> >
>> >However the script hangs with pcre version 10.34 2019-11-21. This
>seems
>> >like a bug in pcre itself.
>> >
>> >Demo: https://github.com/sharmashivanand/php-hang-demo
>> >
>> >That said, however what is the right way to recover from such a hang
>> >and
>> >continue execution when such external libraries fail? We are the
>> >developers
>> >but the script has a user-base and needs to run in varied
>environments.
>> >
>> >Regards,
>> >Shivanand Sharma
>>
>> Can you pass that work off to another process (a queue or similar)
>and
>> then let the user know when it's completed? That other process could
>have a
>> more specific configuration with it's ini settings (shorter execution
>time,
>> etc). Then it at least won't be blocking the main execution for the
>user
>> interface.
>>
>> Also, do you know it's really hung? Have you tried running a failing
>regex
>> and data set? Is it just very long running? Is there something in the
>regex
>> that performs very badly like a lot of lookaheads, etc?
>>
>> Thanks,
>> Ash
>>

Firstly, please don't top post.

Onto your issue. It looks like you're trying to look for specific Meta information in image files. You're loading in a 1MB file to look for a small bit of text. 

Testing this locally doesn't appear to hang. Locally though my version of pcre is 10.32 and pcre Unicode version is 11.0.0.

Have you tried changing any elements here to see what is causing the issue? Try a smaller image, or a slightly reduced regex.
Thanks,
Ash




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux