What are the rules for destroying v8::Global?

33 views
Skip to first unread message

Erik Corry

unread,
Dec 19, 2024, 8:54:55 AM12/19/24
to v8-...@googlegroups.com
Do you have to have entered the isolate to call the destructor of v8::Global?

Here we have https://chromium.googlesource.com/v8/v8.git/+/da4e529cfddb93e7166666c447a94d173e1e682f/test/cctest/test-serialize.cc#548 a Global that is above the isolate scope, so it gets destroyed after the isolate scope was destroyed, and the isolate was exited.  Is this OK/harmless/bad taste?

We could swap those and add a DCHECK in the Global destructor to ensure there is a current isolate.

-- 
Erik

dinf...@chromium.org

unread,
Dec 20, 2024, 5:46:15 AM12/20/24
to v8-dev
It doesn't seem to be necessary in this particular case because we reach the isolate from the global handle location and I wouldn't expect this to change. But IMHO stuff like this should be covered by the Isolate::Scope in general. Things can change under-the-hood and suddenly an API function starts to require the Isolate::Scope. I've personally had to extend Isolate::Scopes in tests already.

Best,
Dominik

Erik Corry

unread,
Dec 20, 2024, 6:06:49 AM12/20/24
to v8-...@googlegroups.com
In that case we could start to enforce it.  I had a go here: https://chromium-review.googlesource.com/c/v8/v8/+/6108854

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/v8-dev/43b40db8-17a7-4d27-bb72-b8f2624d5d98n%40googlegroups.com.

Erik Corry

unread,
Dec 20, 2024, 6:45:49 AM12/20/24
to v8-...@googlegroups.com
It looks like the content_shell doesn't like that assert.  Test failure on the code review.
Reply all
Reply to author
Forward
0 new messages