php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59949 Scoping issues cause fatal error (v8::HandleScope)
Submitted: 2011-09-12 15:42 UTC Modified: 2015-03-13 14:55 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: westie at typefish dot co dot uk Assigned: stesie (profile)
Status: Closed Package: v8js (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: westie at typefish dot co dot uk
New email:
PHP Version: OS:

 

 [2011-09-12 15:42 UTC] westie at typefish dot co dot uk
Description:
------------
Using the below code, I get the error stated even further down 
the code.

If I call the V8Function closure in TestClass::setMethod(), it 
will work perfectly.

However, when I call it in the global scope (as demonstrated) 
it will error. It will also error if I call the closure in 
TestClass::Method() as well.

Reproduce code:
---------------
class Engine
{
	private
		$v8;
	
	
	public function __construct()
	{
		$this->v8 = new v8js("php");
		
		$this->v8->method = function($c)
		{
			TestClass::setMethod($c);
		};
		
		$this->run(" php.method(function(s) { print(s + '!'); }) ");
	}
	
	
	public function run($s)
	{
		return $this->v8->executeString($s);
	}
}



class TestClass
{
	private static
		$cMethod = null;
	
	
	public static function setMethod(V8Function $cMethod)
	{
		self::$cMethod = $cMethod;
	}
	
	public static function Method()
	{
		return self::$cMethod;
	}
}


$e = new Engine();

$c = TestClass::Method();

echo $c("hello"); # Line number: 54

Expected result:
----------------
hello!

Actual result:
--------------
PHP Fatal error:  v8::HandleScope::CreateHandle() Cannot 
create a handle without a HandleScope in 
/home/Westie/Development/V8Js.php on line 54
PHP Stack trace:
PHP   1. {main}() /home/Westie/Development/V8Js.php:0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-20 19:52 UTC] stesie at brokenpipe dot de
This was addressed with issues #33 and #39 over at Github issue tracker back in 2013.  See for details:

https://github.com/preillyme/v8js/issues/33
https://github.com/preillyme/v8js/pull/39

Tried out the code provided here against recent master version, works as expected (meanwhile).

cheers
  ~stesie
 [2015-03-13 14:55 UTC] stesie@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stesie
 [2015-03-13 14:55 UTC] stesie@php.net
no feedback, hence closing now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC