The stack guard should be checked on every call and on every back edge
of a loop in JS, so it should be happening quite fast. Are you seeing
that it doesn't immediately stop when you return to JS?

On Wed, Apr 22, 2026 at 5:59 PM Noa <[email protected]> wrote:
>
> Hi all,
>
> I'm using `v8::Isolate::TerminateExecution` for a couple of different things, 
> and am trying to make sure that execution will stop as soon as possible after 
> it's requested. In one place, we call TerminateExecution inside of a host 
> function, in the context of a HandleScope, and I'd like to make sure that 
> execution doesn't continue in JS after that function returns (currently, 
> `IsExecutionTerminating() == false` directly after calling 
> TerminateExecution). I also want to check that there's no execution 
> termination in-queue at the start of the call of a host function.
>
> Looking at the v8 source, it seems like 
> `v8::internal::StackGuard::HandleInterrupts` (or perhaps 
> `v8::internal::StackLimitCheck::HandleStackOverflowAndTerminationRequest`) 
> would be the ideal function to call in both of these situations, but neither 
> are exposed in the public API. Would it be reasonable to expose a 
> `v8::Isolate::HandleInterrupts` method that would forward to one of those 
> internal functions?
>
> Alternatively, my first case could be fixed by a non-thread-safe 
> `v8::Isolate::TerminateExecutionNow`, which directly calls 
> `v8::internal::Isolate::TerminateExecution` (i.e, 
> `Throw(termination_exception)`). This would be nice to have, but not 
> fundamentally different from `TerminateExecution(); HandleInterrupts()`.
>
> In any case, I'd be willing to submit a patch implementing this method, if 
> that would be welcomed.
>
> Best,
> Noa
>
> --
> --
> v8-dev mailing list
> [email protected]
> 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 [email protected].
> To view this discussion visit 
> https://groups.google.com/d/msgid/v8-dev/d104b942-e71d-469f-893c-ad04e805ad14n%40googlegroups.com.



-- 
-- 
Erik Corry, working on V8 at Cloudflare

-- 
-- 
v8-dev mailing list
[email protected]
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/v8-dev/CAHZxHpiML-hELq%2BgMWUfRYYNz1czON-ucztrg8OAUYCQhGSGHg%40mail.gmail.com.

Reply via email to