Skip to content

Unexpected TypeError: Illegal invocation (same as #262 but how to reproduce the problem) #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrisbckr opened this issue Dec 3, 2018 · 6 comments

Comments

@chrisbckr
Copy link
Contributor

class BaseClass {
	public function bla() {
	    echo "print bla";
	}
}

class Foo extends BaseClass {
    
}

class Bar extends BaseClass {
}

$v8 = new V8Js('PHP');
$v8->Foo = new Foo();
$v8->Bar = new Bar();

$code = <<<EOT

var_dump(PHP.Foo);
var_dump(PHP.Bar);

var_dump(PHP.Foo.bla());
var_dump(PHP.Bar.bla());
EOT;

$v8->executeString($code, 'test');

Result:

object(Foo)#1792350 (1) {
  ["bla"] =>
  object(Closure)#914656 {
      function () { [native code] }
  }
}
object(Bar)#1323981 (1) {
  ["bla"] =>
  object(Closure)#914656 {
      function () { [native code] }
  }
}
print blaNULL
PHP Fatal error:  Uncaught V8JsScriptException: test:6: TypeError: Illegal invocation in /root/v8js/teste.php:28
Stack trace:
#0 /root/v8js/teste.php(28): V8Js->executeString('\nvar_dump(PHP.F...', 'test')
#1 {main}
  thrown in /root/v8js/teste.php on line 28

Fatal error: Uncaught V8JsScriptException: test:6: TypeError: Illegal invocation in /root/v8js/teste.php:28
Stack trace:
#0 /root/v8js/teste.php(28): V8Js->executeString('\nvar_dump(PHP.F...', 'test')
#1 {main}
  thrown in /root/v8js/teste.php on line 28

PHP 7.0.32-2+0 20181015120515.7+jessie~1.gbpa6b8cf (cli) (built: Oct 15 2018 19:38:45) ( NTS )
libv8 7.2.99

Originally posted by @chrisbckr in #262 (comment)

@kolyan-r
Copy link

kolyan-r commented Jan 30, 2019

Hi, i caught the same problem when wrote my code :(
OS Ubuntu 18.04
PHP PHP 7.1.26-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jan 11 2019 14:13:49)
V8 7.0.276.32
phpv8 revision 85097c1d6877165582c1a58754f36b12a4b98055

@niklas-heer
Copy link

We are having the same issue.
In the meantime is there maybe a workaround?

@juan-morales
Copy link

Tested on Ubuntu 18.04

With the following configuration:

$ php --ri v8js

**v8js

V8 Javascript Engine => enabled
V8 Engine Compiled Version => 7.6.57
V8 Engine Linked Version => 7.6.57
Version => 2.1.0

Directive => Local Value => Master Value
v8js.flags => no value => no value
v8js.icudtl_dat_path => no value => no value
v8js.use_date => 0 => 0
v8js.use_array_access => 0 => 0**

And I am getting the exact same result.

Any advice?

@juan-morales
Copy link

I can Confirm this code breaks also in the coker image provided here:

https://hub.docker.com/r/stesie/v8js/

@juan-morales
Copy link

juan-morales commented Jun 5, 2019

ok , workaround for this issue .... BUT NEEDS TO BE INVESTIGATED

class BaseClass {
	public function bla() {
	    echo "print bla";
	}
}

class Foo extends BaseClass {
    
}

class Bar extends BaseClass {
}

$v8 = new V8Js('PHP');
$v8->Foo = new Foo();
$v8->Bar = new Bar();

$code = <<<EOT

var_dump(PHP.Foo);
var_dump(PHP.Bar);

var_dump(PHP.Foo.__call("bla", []));
var_dump(PHP.Bar.__call("bla", []));
EOT;

$v8->executeString($code, 'test');

@stesie
Copy link
Member

stesie commented Jun 23, 2019

Fixed by #416, shipped with v8js 2.1.1

@stesie stesie closed this as completed Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants