phpv8 / php-v8

PHP extension for V8 JavaScript engine
https://php-v8.readthedocs.io
MIT License
217 stars 14 forks source link

Uncaught fatal error when snapshot v8 version doesn't match current v8 version #73

Closed pinepain closed 6 years ago

pinepain commented 6 years ago
"# Fatal error in ../../src/snapshot/snapshot-common.cc, line 286"
"# Version mismatch between V8 binary and snapshot."
"#   V8 binary version: 6.3.257"
"#    Snapshot version: 6.3.248"
"# The snapshot consists of 1482496 bytes and contains 1 context(s)."
"#"
"Received signal 4 ILL_ILLOPN 7f6b1a7b28e9"
pinepain commented 6 years ago

I think we can use v8::ScriptCompiler::CachedDataVersionTag() to prepend version tag to any cache data and validate it on loading.

pinepain commented 6 years ago

I decided that in advance to v8 version it would be wise to store our own field value to be able to invalidate caches when something changes in extension itself which may affect snapshots behavior.

pinepain commented 6 years ago

I'm thinking more about following the approach like with script cache class and do not throw exception in Isolate constructor when snapshot is invalid and set a flag on it that it was rejected so that it won't abrupt execution. It's end-user responsibility to validate that caches and snapshots are valid. We could also expose a tag we store alongside snapshot data to verify it with a runtime tag and check whether snapshot valid or not. Any thoughts?