Commit aa9aac3c authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[isolate] Fix CountUsage calls without a current native context

The blink use counter callback requires a current native context to
exist, and will crash if that is not the case. We can fix this V8 by
deferring the count. A cleaner (future) fix would be to either pass
the native context to the callback, or remove the requirement in
blink.

Bug: v8:9496,v8:10460
Change-Id: I8832d02088ba422c3a27638cee4dacbaaf6f39b4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2167394Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67421}
parent e29c62b7
......@@ -4249,9 +4249,15 @@ void Isolate::SetUseCounterCallback(v8::Isolate::UseCounterCallback callback) {
}
void Isolate::CountUsage(v8::Isolate::UseCounterFeature feature) {
// The counter callback may cause the embedder to call into V8, which is not
// generally possible during GC.
if (heap_.gc_state() == Heap::NOT_IN_GC) {
// The counter callback
// - may cause the embedder to call into V8, which is not generally possible
// during GC.
// - requires a current native context, which may not always exist.
// TODO(jgruber): Consider either removing the native context requirement in
// blink, or passing it to the callback explicitly.
if (heap_.gc_state() == Heap::NOT_IN_GC && !context().is_null()) {
DCHECK(context().IsContext());
DCHECK(context().native_context().IsNativeContext());
if (use_counter_callback_) {
HandleScope handle_scope(this);
use_counter_callback_(reinterpret_cast<v8::Isolate*>(this), feature);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment