🐛 exec_check also needs CHECK_INTERRUPT

This commit is contained in:
ValKmjolnir 2025-02-05 17:56:57 +08:00
parent e405c3e6d4
commit 09cd3027e9
1 changed files with 11 additions and 10 deletions

View File

@ -569,15 +569,15 @@ void vm::run(const codegen& gen,
); );
#ifndef _MSC_VER #ifndef _MSC_VER
// using labels as values/computed goto
// Define an interrupt check macro for computed goto mode. // interrupt check macro for computed goto mode.
#define CHECK_INTERRUPT { \ #define CHECK_INTERRUPT { \
if (interrupt_ptr && interrupt_ptr->load()) { \ if (interrupt_ptr && interrupt_ptr->load()) { \
throw std::runtime_error("VM execution interrupted by timeout"); \ throw std::runtime_error("VM execution interrupted by timeout"); \
} \ } \
} }
// using labels as values/computed goto
const void* oprs[] = { const void* oprs[] = {
&&vmexit, &&vmexit,
&&repl, &&repl,
@ -705,15 +705,16 @@ vmexit:
return; return;
#ifndef _MSC_VER #ifndef _MSC_VER
// may cause stackoverflow // IR which may cause stackoverflow
#define exec_check(op) {\ #define exec_check(op) {\
op();\ op();\
CHECK_INTERRUPT;\
if (ctx.top<ctx.canary)\ if (ctx.top<ctx.canary)\
goto *code[++ctx.pc];\ goto *code[++ctx.pc];\
die("stack overflow");\ die("stack overflow");\
goto *code[++ctx.pc];\ goto *code[++ctx.pc];\
} }
// do not cause stackoverflow // IR which does not cause stackoverflow
#define exec_nodie(op) {\ #define exec_nodie(op) {\
op();\ op();\
CHECK_INTERRUPT;\ CHECK_INTERRUPT;\