|  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
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
 [2011-09-12 15:42 UTC] westie at typefish dot co dot uk
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
	public function __construct()
		$this->v8 = new v8js("php");
		$this->v8->method = function($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:

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


Add a Patch

Pull Requests

Add a Pull Request


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:

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

 [2015-03-13 14:55 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: stesie
 [2015-03-13 14:55 UTC]
no feedback, hence closing now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 06:01:28 2024 UTC