The isolate can indeed be re-entered and, in that case, a counter is 
increased.
The isolate is only exited when the counter becomes zero.
This is indeed a different behaviour from what the documentation 
<https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-locker.h;drc=65034fdf545d2f937dd05f1aa535c39ba21ccac5;l=69>
 
specifies for the Locker/Unlocker.

Do you have a scenario where it is not possible or convenient to properly 
exit the isolate (using the right number of Exit calls) before using the 
Unlocker?

If thread A has entered the isolate (N times) and then uses the Unlocker 
without properly exiting (N times), then it can still use the isolate.
If at the same time thread B uses the Locker and enters the isolate, we end 
up with two threads using the isolate simultaneously.


On Tuesday, January 16, 2024 at 4:56:51 PM UTC+1 me...@redis.com wrote:

> Nikos I am still confuse.
>
> The documentation also state that reenter the isolate is allowed: 
> https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-isolate.h;l=731
> So before creating an unlocker we must exit the isolate the number of 
> times we entered it (and then re-enter it again the same number of times 
> after the unlocker is destroyed)?
>
> Or is there some mechanism that handles it when we exit/enter the isolate?
>
> On Tuesday 16 January 2024 at 13:58:19 UTC+2 Meir Shpilraien wrote:
>
>> Thanks Nikos,
>>
>> You are right, I missed it in our documentation. Will fix our code.
>>
>> Thank you for the quick response.
>>
>> On Tuesday 16 January 2024 at 13:46:19 UTC+2 niko...@google.com wrote:
>>
>>> Hi Meir,
>>>
>>> You are correct about the purpose of the CHECK that I introduced in CL 
>>> 5173257 <https://chromium-review.googlesource.com/c/v8/v8/+/5173257>.
>>>
>>> The documentation 
>>> <https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-locker.h;drc=65034fdf545d2f937dd05f1aa535c39ba21ccac5;l=45>
>>>  
>>> of the Locker/Unlocker API specifies that a thread has to exit the isolate 
>>> before using v8::Unlocker and enter it again afterwards.
>>>
>>> Without seeing your code, I cannot be sure that this is the issue but 
>>> from what you write I suspect that it is. It should also be very easy to 
>>> fix.
>>>
>>> See here for a similar fix that had to be made in chromium: CL 5168625 
>>> <https://chromium-review.googlesource.com/c/chromium/src/+/5168625>.
>>>
>>> Best regards,
>>> Nikos.
>>>
>>> On Tuesday, January 16, 2024 at 12:18:22 PM UTC+1 me...@redis.com wrote:
>>>
>>> Hey,
>>>
>>> We recently encounter an issue in which our code, when run on V8 main 
>>> branch, crashes with this fatal error:
>>> #
>>> # Fatal error in ../../src/execution/isolate.cc, line 4996
>>> # Check failed: current_thread_id_ == thread_id (<unprintable> vs. 
>>> <unprintable>).
>>> #
>>> #
>>> #
>>>
>>> I saw that this check was added recently on this PR: 
>>> https://chromium-review.googlesource.com/c/v8/v8/+/5173257
>>>
>>> Its purpose is to verify a correct use of entering and existing an 
>>> isolate. But I do not see it is taking into consideration the 
>>> Locker/Unlocker API. In case the current thread uses Unlocker and then 
>>> another thread tries to enter the isolate it will failed.
>>>
>>> Is my analysis correct or am I missing something?
>>> Thanks,
>>> Meir
>>>
>>>

-- 
-- 
v8-dev mailing list
v8-dev@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/1c5f78f7-74f7-4cce-815c-9f670d8145c6n%40googlegroups.com.

Reply via email to