Bug #78512 [Opn->Ver]: Cannot make preload work

From: Date: Mon, 21 Oct 2019 11:22:21 +0000
Subject: Bug #78512 [Opn->Ver]: Cannot make preload work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223342@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78512&edit=1

 ID:                 78512
 Updated by:         remi@php.net
 Reported by:        nicolas dot grekas+php at gmail dot com
 Summary:            Cannot make preload work
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            opcache
 PHP Version:        7.4.0RC1
 Block user comment: N
 Private report:     N

 New Comment:

Verified, with a trivial reporoducer

Normal user
$ echo '<?php class Foo {}' > Foo.php
$ php -d opcache.preload=Foo.php -r 'var_dump(class_exists("Foo"));'
bool(true)

Root user
# php -d opcache.preload_user=remi -d opcache.preload=Foo.php -r
'var_dump(class_exists("Foo"));'
bool(false)


Previous Comments:
------------------------------------------------------------------------
[2019-10-07 10:24:24] hrvoje dot novosel at gmail dot com

I've been testing preload today on 7.4RC3 and also can't get it to work.
I don't know if its the same bug as this or unrelated, I'm testing with 2 simple scripts:

preload.php
<?php
class A{}

test.php
<?php
require_once('preload.php');
class B extends A {}
echo "ok";

when I run this without preload it works fine, when I enable preload
opcache.preload=/sambafs/preload.php
opcache.preload_user=apache
(I'm using php-fpm)
and try loading test.php I get
Fatal error: Uncaught Error: Class 'A' not found in ...

if I dump opcache stats I can see it there
[preload_statistics] => Array
        (
            [memory_consumption] => 3160
            [classes] => Array
                (
                    [0] => A
                )

            [scripts] => Array
                (
                    [0] => /sambafs/preload.php
                )

        )
but its not under get_declared_classes

------------------------------------------------------------------------
[2019-09-17 12:51:02] nicolas dot grekas+php at gmail dot com

I confirm that this error happens as root, and also that preloading works when running as non-root,
thank you \o/

------------------------------------------------------------------------
[2019-09-16 18:28:18] jhdxr@php.net

I think I find the key to reproduce this issue. You have to be root, and run with
opcache.preload_user.

e.g. 
sudo ~/proj/php-src/sapi/cli/php -S localhost:8000 -t preload-failures/public/
-dopcache.preload=preload-failures/var/cache/prod/srcApp_KernelProdContainer.preload.php
-dopcache.preload_user=jhdxr


Hope this helps.

------------------------------------------------------------------------
[2019-09-16 16:00:17] jhdxr@php.net

I confirm I can reproduce this issue with latest devilbox/php-fpm-7.4 docker image(588dad05d58f). 



however, I got another error when I tried with my dev environment (latest 7.4 branch,
6417c507ce511ecfc5d3f3818ffb01435f3086ee).

./configure --disable-all --disable-cgi --disable-phpdbg --enable-cli --enable-debug
--enable-opcache 

./sapi/cli/php -S localhost:8000 -t ~/proj/php-src-tests/bug78512/preload-failures/public/
-dopcache.preload=~/proj/php-src-tests/bug78512/preload-failures/var/cache/prod/srcApp_KernelProdContainer.php

php: /home/jhdxr/proj/php-src/Zend/zend_string.c:264: zend_string_init_interned_permanent: Assertion
`permanent' failed.



I'll try a full build later in my dev env to see if I can reproduce this issue.

------------------------------------------------------------------------
[2019-09-13 07:58:02] nikic@php.net

I've tried with the prod env now to see if that makes a difference, but can't reproduce
with that either. In that case I get a 404 page, but no errors.

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


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=78512


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


Thread (13 messages)

« previous php.bugs (#223342) next »