[php-src] Issue #13145: strtok() fails to tokenize the input when passed a literal string when opcache is enabled

From: Date: Sun, 14 Jan 2024 02:36:44 +0000
Subject: [php-src] Issue #13145: strtok() fails to tokenize the input when passed a literal string when opcache is enabled
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246260@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13145 Author: TRowbotham ### Description The following code: ```php <?php $tok = strtok("This is\tan example\nstring", " \n\t"); while ($tok !== false) { $tok = strtok(" \n\t"); } ``` Resulted in this output: ``` Infinite loop ``` But I expected this output instead: ``` Not an infinite loop ``` The above code results in an infinite loop on PHP 8.3.x and master when opcache is enabled. It works as expected on PHP 8.1.x and 8.2.x with opcache enabled. It also works as expected when opcache is disabled on PHP 8.3.x and master. If you change the example to use a variable as input instead of a literal string, then it works as expected on PHP 8.3.x and master when opcache is enabled. ```php <?php $string = "This is\tan example\nstring"; $tok = strtok($string, " \n\t"); while ($tok !== false) { $tok = strtok(" \n\t"); } ``` ### PHP Version PHP 8.3.1 ### Operating System Ubuntu 20.04/WSL

« previous php.bugs (#246260) next »