php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58884 Returning empty string from static function causes seg fault
Submitted: 2009-10-08 16:49 UTC Modified: 2010-02-20 15:35 UTC
From: scottsteffens at gmail dot com Assigned:
Status: Duplicate Package: spidermonkey (PECL)
PHP Version: 5.3.0RC4 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 + 33 = ?
Subscribe to this entry?

 
 [2009-10-08 16:49 UTC] scottsteffens at gmail dot com
Description:
------------
When a registered class accesses a static function that returns an empty string "", it results in a segmentation fault.

This bug appears to be distinct from #16865 since it likely has to do with type conversion, but all the software and environment settings are the same.

Reproduce code:
---------------
<?php
$app = new App();
$app->run();

class App {	
	public function run () {
		$context = new JSContext();
		$context->registerClass( 'TimeObject' );
		echo $context->evaluateScript( 'var t = new TimeObject(); t.getTime();' );
	}
	
	static function getString() {
		return ''; // <-- empty string causes seg fault
		//return ' '; // <-- a space won't cause seg fault
	}
}

class TimeObject {
	public function getTime () {
		return App::getString();
	}
}
?>

Expected result:
----------------
getTime() returns an empty string

Actual result:
--------------
Apache error_log:
[Thu Oct 08 13:43:29 2009] [notice] child pid 5629 exit signal Segmentation fault (11)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-27 10:39 UTC] drslump at pollinimini dot net
This use case seems to also be fixed by the patch supplied in bug 16876 (http://pecl.php.net/bugs/bug.php?id=16876)
 [2010-02-20 15:35 UTC] c dot robin at smartphp dot org
It is indeed fixed by the corrective used for 16876
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 20:01:31 2024 UTC