php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70237 Empty while and do-while segmentation fault with opcode on CLI enabled
Submitted: 2015-08-11 08:43 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: notrix at gmail dot com Assigned:
Status: Closed Package: opcache
PHP Version: 5.5.28 OS: Ubuntu 14.04
Private report: No CVE-ID:
 [2015-08-11 08:43 UTC] notrix at gmail dot com
Description:
------------
If I enable opcache on cli environment (opcache.enable_cli) and run my test.php script I get: "[1]    19066 segmentation fault (core dumped)  php test.php"

This happens only if while (or do-while) condition is variable and content (between curly braces) is empty or contains only comments.

Actually the code makes no sense, but I had to debug few hours and found this exact code with only comment "// TODO: .." in do-while braces. Commenting out whole loop block fixed issue, but it's still a bug I think.

Reproduced on php 5.5.27 and 5.6.11

Test script:
---------------
<?php

if ((int) ini_get('opcache.enable_cli') !== 1) {
    throw new Exception('Opcode cache must be enabled on CLI environment');
}

function neverUsed() {
    $bool = false;
    while ($bool) { };
    // Same with: do { } while ($bool);
}

echo "OK";

Expected result:
----------------
Expected to see OK printed

Actual result:
--------------
[1]    19066 segmentation fault (core dumped)  php test.php

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-11 13:49 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=79cd9a18b505e8d77d16abe6ef146d4b4ff02ed9
Log: Fixed bug #70237 (Empty while and do-while segmentation fault with opcode on CLI enabled).
 [2015-08-11 13:49 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-08-11 14:37 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=79cd9a18b505e8d77d16abe6ef146d4b4ff02ed9
Log: Fixed bug #70237 (Empty while and do-while segmentation fault with opcode on CLI enabled).
 [2015-08-18 16:24 UTC] ab@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=79cd9a18b505e8d77d16abe6ef146d4b4ff02ed9
Log: Fixed bug #70237 (Empty while and do-while segmentation fault with opcode on CLI enabled).
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Fri Apr 28 04:01:59 2017 UTC