Bug #81096 [NEW]: Inconsistent opcache behavior with variables passed by reference to mysqli

From: Date: Tue, 01 Jun 2021 18:43:11 +0000
Subject: Bug #81096 [NEW]: Inconsistent opcache behavior with variables passed by reference to mysqli
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234150@lists.php.net to get a copy of this message
From: nickdnk at hotmail dot com Operating system: Linux/docker PHP version: 8.0.6 Package: opcache Bug Type: Bug Bug description:Inconsistent opcache behavior with variables passed by reference to mysqli Description: ------------ Hello I have a hard time describing what the problem here actually is, as I'm unsure of the root cause. I have created a complete docker-compose setup that demonstrates the behavior, which is available here: https://github.com/nickdnk/php-bug-demo Clone it and run docker-compose up -d, wait for the containers to boot and composer to run (just wait like 20 seconds or look at the container logs) then navigate to localhost:8001 for PHP 8.0.6 and localhost:8002 for PHP 7.4.15. Notice that the output is not identical and that PHP 8 got it wrong. Test script: --------------- https://github.com/nickdnk/php-bug-demo See the src/Test.php class. I pass $bind_integer by reference to $stmt->bind_result(), then set it to 0 and call fetch(). Removing the "set to 0"-line causes the problem to go away, but that does not explain what's going on or why this changed between 7 and 8. The reason I use the Container class to return it is that if I read the variable, error_log or var_dump it directly, it behaves as expected, which is very weird (?). Removing the (int) cast also causes it to behave as expected. Disabling opcache "fixes" the bug, so it also is not present when using Xdebug, which makes it very hard to debug (and reproduce, mind you), hence the kind of complicated setup to demonstrate it. If you modify the scripts (for debugging purposes), navigate to localhost:8001/opcache or localhost:8002/opcache to reset the opcache. Otherwise you would have to restart the web containers. The PHP images used are the official ones from https://hub.docker.com/_/php with Composer, MySQLi, PDO etc. added to them, so everything is more or less default. I only changed the opcache configuration as visible in the php.ini file attached to the containers, as this is not enabled by default. You could probably take some of these lines away though: FROM php:8.0.6-apache # or 7.4.15 RUN apt-get update && \ apt-get install -y libpng-dev \ libjpeg-dev \ libfreetype6-dev \ libzip-dev \ git \ zip \ unzip \ mariadb-client RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ RUN docker-php-ext-install \ mysqli \ gd \ exif \ zip \ pdo_mysql \ bcmath RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer && \ apt-get -y autoremove && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -- Edit bug report at https://bugs.php.net/bug.php?id=81096&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81096&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81096&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81096&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81096&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81096&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81096&r=support Expected behavior: https://bugs.php.net/fix.php?id=81096&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81096&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81096&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81096&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81096&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81096&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81096&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81096&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81096&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81096&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81096&r=mysqlcfg

« previous php.bugs (#234150) next »