php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63548 Segmentation fault in recursive function
Submitted: 2012-11-17 14:18 UTC Modified: 2012-11-20 03:04 UTC
From: admin at phpcode dot us Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.18 OS: OpenBSD 5.2 amd64
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at phpcode dot us
New email:
PHP Version: OS:

 

 [2012-11-17 14:18 UTC] admin at phpcode dot us
Description:
------------
I user OpenBSD 5.2 amd64. with php 5.3.17 port from current port tree with small 
fix to success build it on 5.2 and fix to use latest version. 
Run test script from CLI and get segfault.


Test script:
---------------
#!/usr/local/bin/php -n
<?php
function test() {
    static $i = 0;
    if ($i === PHP_INT_MAX) {
        echo $i . PHP_EOL;
        return ;
    }
    if (!($i % 256)) {
        echo $i . PHP_EOL;
    }
    $i++;
    test();
}
test();

Expected result:
----------------
$ ./test.php
a lot of input ($i % 256)
9223372036854775807

Actual result:
--------------
$ ./test.php
0
...
11776
Segmentation fault (core dumped)

$ gdb -c php-5.3.core /usr/local/bin/php-5.3

#0  0x00000000006b9dac in vspprintf ()
#1  0x0000000000723cfa in zend_exception_error ()
#2  0x0000000000703630 in _convert_to_string ()
#3  0x000000000070c9d4 in zend_make_printable_zval ()
#4  0x000000000070317b in concat_function ()
#5  0x0000000000733876 in zend_get_user_opcode_handler ()
#6  0x0000000000735260 in execute ()
#7  0x0000000000683d4c in php_url_encode_hash_ex ()
#8  0x0000000000735c7c in execute ()
#9  0x0000000000735260 in execute ()
......................................
#58400 0x00000000008ef760 in execute ()
#58401 0x00000000008f53cf in execute ()
#58402 0x00000000008ee560 in execute ()
#58403 0x00000000007bd39a in php_url_encode_hash_ex ()
#58404 0x00000000007bd3e1 in php_url_encode_hash_ex ()
#58405 0x00000000008b4c76 in zend_execute_scripts ()
#58406 0x0000000000835571 in php_execute_script ()
#58407 0x00000000009ae07c in _full_mem_check ()
#58408 0x0000000000428b71 in ___start ()
#58409 0x0000000000000000 in ?? ()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-19 22:48 UTC] mail+php at requinix dot net
You overflowed the stack. Of course it'll segfault.
 [2012-11-20 03:04 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-11-20 03:04 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

actually, your bt seems not generated accurately by the test script, right?

thanks for  mail+php at requinix dot net 's explanation
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 12:01:29 2025 UTC