Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] GCC -foptimize-strlen and bug #76510

Posted by Michael Moravec 
Michael Moravec
[PHP-DEV] GCC -foptimize-strlen and bug #76510
August 04, 2018 10:50PM
Hi,

yesterday I was digging into the bug #76510:
https://bugs.php.net/bug.php?id=76510
A strange PHAR- and streams-related issue that only happens for some
users/binaries.

I was able to trace it down to a GCC optimization "optimize-strlen".
Here's when the bug does and does not reproduce:
gcc-8 with -O0 works
gcc-8 with -O1 works
gcc-8 with -O2 does not work
gcc-8 with -O3 does not work
gcc-8 with -Og works
gcc-8 with -Os works

With some further testing, I was able to find a workaround: -O2
-fno-optimize-strlen

I bisected this issue to the commit
513b0093c2b480bb752fb354012f42c446769486:
Refactor php_url struct to save memory dup in common cases
https://github.com/php/php-src/commit/513b0093c2b480bb752fb354012f42c446769486
(bisect log is in the bug report)

To confirm:
git checkout 513b0093c2b480bb752fb354012f42c446769486 + gcc-8 + -O2: Fatal
error
git checkout 513b0093c2b480bb752fb354012f42c446769486^ + gcc-8 + -O2: works

Unfortunately this is where my journey ends - my C/GCC knowledge is not
sufficient enough to analyse this further.

I'd like to ask someone to take over from here so we can see this issue
fixed in the next 7.3 pre-release.

Thank you,
M.
Dan Ackroyd
Re: [PHP-DEV] GCC -foptimize-strlen and bug #76510
August 04, 2018 11:20PM
On 4 August 2018 at 21:46, Michael Moravec <[email protected]> wrote:
>
> Unfortunately this is where my journey ends - my C/GCC knowledge is not
> sufficient enough to analyse this further.
>

Hi Michael,

If you can reproduce the issue, it would be appropriate for you to
open a bug report with the GCC people, presumably at
https://gcc.gnu.org/bugzilla/

What can be done to work around optimisation bugs is quite limited.

cheers
Dan
Ack

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Nikita Popov
Re: [PHP-DEV] GCC -foptimize-strlen and bug #76510
August 05, 2018 12:00AM
On Sat, Aug 4, 2018 at 11:18 PM, Dan Ackroyd <[email protected]> wrote:

> On 4 August 2018 at 21:46, Michael Moravec <[email protected]> wrote:
> >
> > Unfortunately this is where my journey ends - my C/GCC knowledge is not
> > sufficient enough to analyse this further.
> >
>
> Hi Michael,
>
> If you can reproduce the issue, it would be appropriate for you to
> open a bug report with the GCC people, presumably at
> https://gcc.gnu.org/bugzilla/
>
> What can be done to work around optimisation bugs is quite limited.
>

More likely than not this is a bug on our side triggered by this
optimization, not a bug in GCC. A run through valgrind might reveal
something.

Nikita
Sorry, only registered users may post in this forum.

Click here to login