Fwd: Memory corruption bug
| From: | Tiago Marques | Date: | Fri, 22 May 2015 18:50:53 +0000 |
| Subject: | Fwd: Memory corruption bug | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324940@lists.php.net to get a copy of this message | ||
Hi Cristoph,
Cleaned up my code and submitted bug at https://bugs.php.net/bug.php?id=69693
Pretty sure this is a PHP bug, probably related to an incomplete port
to x32 ABI.
Let's see what knowledgeable people can say about this.
Best regards,
Tiago
On Wed, May 20, 2015 at 12:08 PM, Christoph Becker <cmbecker69@gmx.de> wrote:
> Tiago Marques wrote:
>
>> I've been running a PHP server with Wordpress for a good while now,
>> when I stumbled upon a problem uploading some posts, where the script
>> would enter a loop and run till it crashed, running out of process
>> memory.
>>
>> I managed to create a test case based on Wordpress's code and my HTML
>> content, then narrowed down the loop and variables that are being
>> (apparently) corrupted in some way:
>>
>> The relevant variables are $i and $l, which at the time the code blows
>> up, store 68 and 71, as integers. These are summed as a parameter to
>> substr() in the loop, which gets a float instead of the value "139".
>> The rest of the code runs a $text var and a $newtext var, upon which
>> the force_balance_tags() function from formatting.php iterates.
>> These are the dumps at the time when the code does bad things:
>>
>> $i: int(68)
>> $l: int(71)
>> $i + $l: float(9.7837007760303E+18)
>>
>> Only the sum gives wrong results, the other operations like
>> subtraction and multiplication produce accurate results. This only
>> happens in this iteration of the loop.
>>
>> Previously, I managed to circumvent the bug by copying the $text
>> variable into another variable, just before the line with the two
>> substr() operations on $text, which was were the code was having
>> problems. After a while of successfully posting my edits without
>> knowing anything more about the problem, I noticed this might be a
>> more widespread problem when Wordpress started producing garbage HTML
>> on some strings, in other places, and went looking deeper.
>>
>> I tried to find a way to maybe debug this but have no idea of how to
>> look at process memory in php, or what to look for. I have a test case
>> to submit but am unsure if I should file a bug or if I'm posting in
>> the right mailing list at all.
>
> If you have a small self-contained test case to demonstrate the erratic
> behavior, I suggest you file a bug report on <https://bugs.php.net/
>>.
> If you are not sure whether it is a bug in PHP, you can post the code
> here. If the reproduce code is long, it might be best to post it
> somewhere else (e.g. <https://gist.github.com/>), and
> only send a link
> to this mailing list resp. the bug tracker.
>
> --
> Christoph M. Becker
>