Bug #78175 [ReO->Csd]: Preloading segfaults at preload time and at runtime

From: Date: Mon, 22 Jul 2019 09:26:04 +0000
Subject: Bug #78175 [ReO->Csd]: Preloading segfaults at preload time and at runtime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221886@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78175&edit=1

 ID:                 78175
 Updated by:         dmitry@php.net
 Reported by:        nicolas dot grekas+php at gmail dot com
 Summary:            Preloading segfaults at preload time and at runtime
-Status:             Re-Opened
+Status:             Closed
 Type:               Bug
 Package:            opcache
 PHP Version:        7.4.0alpha1
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Commit 60dca2295d4eb87873e85bed24880a948a4049cc fixes a related crash


Previous Comments:
------------------------------------------------------------------------
[2019-07-21 19:42:25] nicolas dot grekas+php at gmail dot com

Sorry, this still segfaults for me, here is the code:
https://github.com/nicolas-grekas/symfony/releases/download/php-bugs/preload-php-bug-78175.zip

------------------------------------------------------------------------
[2019-06-24 17:38:52] dmitry@php.net

Should be fixed by https://github.com/php/php-src/commit/0f29fb5cd81d9df4829bc63f704019df910b3075

------------------------------------------------------------------------
[2019-06-21 10:30:25] dmitry@php.net

A partial fix is available at

https://github.com/php/php-src/compare/PHP-7.4...dstogov:bug78175?expand=1

It needs to be extended to support static variables of methods.

------------------------------------------------------------------------
[2019-06-20 12:30:41] nicolas dot grekas+php at gmail dot com

> Although, this is a bug, it's also an interesting unexpected side effect, that allow
> initialization and preloading of big arrays as static properties (e.g. application configuration)

While funny, that's not that interesting to keep: if one wants this, it's always possible
to generate a file with the array and load it. Preloading the default static value is what would be
the most expected, to me at least :)

------------------------------------------------------------------------
[2019-06-19 09:22:31] dmitry@php.net

The problem caused by assignment object to static property of preloaded class, and opcache
doesn't expect objects...

A simpler way to reproduce:

preload.php
-----------
<?php
class Loader {
        static private $loader;

        static function getLoader() {
                if (null !== self::$loader) {
                        return self::$loader;
                }
                return self::$loader = new Loader();
        }
}

Loader::getLoader();
?>

$ USE_ZEND_ALLOC=0 valgrind sapi/cli/php -dopcache.preload=preload.php -r
'var_dump(get_class(Loader::getLoader()));'

Although, this is a bug, it's also an interesting unexpected side effect, that allow
initialization and preloading of big arrays as static properties (e.g. application configuration)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=78175


--
Edit this bug report at https://bugs.php.net/bug.php?id=78175&edit=1


Thread (14 messages)

« previous php.bugs (#221886) next »