php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20120 Calling functions through variables produces seg fault
Submitted: 2002-10-27 09:38 UTC Modified: 2002-10-27 13:54 UTC
From: pcgod at gmx dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4CVS-2002-10-27 OS: Linux, BSDi 4.x
Private report: No CVE-ID: None
 [2002-10-27 09:38 UTC] pcgod at gmx dot net
If I try to call a function from a class and the name of the function is inside a variable php seg faults.
It works fine with php 4.2.3 and if the function isn't inside a class. Some pear script which use this don't produce a crash but give errors about an undefined function with a numeric name. (e.g. Fatal error: Call to undefined function:  138421340() in /usr/lib/php/PEAR.php on line 512)

Example:
<?php
class bugtest {
        function bug() {
                echo "test\n";
        }
}

$test = new bugtest();
$test1 = "bug";
$test->$test1();
?>

Backtrace:

#0  execute (op_array=0x83b64bc) at /home/pcgod/php4/Zend/zend_execute.c:1496
1496                                            tmp = *function_name;
(gdb) bt
#0  execute (op_array=0x83b64bc) at /home/pcgod/php4/Zend/zend_execute.c:1496
#1  0x0822380b in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/pcgod/php4/Zend/zend.c:839
#2  0x081f26f4 in php_execute_script (primary_file=0x5ffff8f0) at /home/pcgod/php4/main/main.c:1542
#3  0x0823aa24 in main (argc=2, argv=0x5ffff994) at /home/pcgod/php4/sapi/cli/php_cli.c:695
#4  0x265dc1eb in __libc_start_main () from /lib/libc.so.6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-27 09:44 UTC] derick@php.net
I can not reproduce this at all, do you run with Zend Engine 1 or Zend Engine 2?

 [2002-10-27 09:51 UTC] pcgod at gmx dot net
Zend Engine 1
 [2002-10-27 09:53 UTC] derick@php.net
Can you post your configure line, and your php.ini file (the one that's actually used).
 [2002-10-27 10:21 UTC] sniper@php.net
I can't reproduce this either with latest CVS..

 [2002-10-27 10:40 UTC] pcgod at gmx dot net
after some test I found the problem... I had bison 1.50 installed which seems to cause some problems with the Zend parser. Downgrading to bison 1.35 solved the problem.
 [2002-10-27 12:25 UTC] msopacua@php.net
Reproduced with bison-1.50.
Segfault identical.

NOT reproducable with bison-1.75, so upgrading should be possible also.
 [2002-10-27 13:24 UTC] sniper@php.net
Can you please try with Bison 1.75?? It seems to fix some bc problems they made in 1.50.. :I

 [2002-10-27 13:54 UTC] sniper@php.net
I added check for bison now into CVS. There were some errors reported with using bison 1.35 too btw. We now require version <= 1.30 >= 1.75 to be sure..

And btw. you don't need to generate these files yourself..
They are generated for releases and snapshots.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 22:01:26 2024 UTC