phpv8/php-v8

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

pinepain opened this issue · 3 comments

"# 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"

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

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.

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?