changed MOO_STACK_PUSH to check process stack overflow

This commit is contained in:
hyunghwan.chung 2019-10-16 09:50:12 +00:00
parent 3f7e4b0953
commit c2458c61cb
2 changed files with 12 additions and 4 deletions

View File

@ -6392,7 +6392,7 @@ static int __execute (moo_t* moo)
END_DISPATCH_LOOP()
return 0;
return (moo->abort_req <= -1)? -1: 0;
}
int moo_execute (moo_t* moo)

View File

@ -113,7 +113,7 @@ enum moo_option_dflval_t
MOO_DFL_LOG_MAXCAPA = MOO_LOG_CAPA_ALIGN * 16,
MOO_DFL_SYMTAB_SIZE = 5000,
MOO_DFL_SYSDIC_SIZE = 5000,
MOO_DFL_PROCSTK_SIZE = 5000
MOO_DFL_PROCSTK_SIZE = 1000
};
typedef enum moo_option_dflval_t moo_option_dflval_t;
@ -1731,11 +1731,19 @@ struct moo_t
};
/* TODO: proper stack bound check when pushing */
/*MOO_ASSERT (moo, (moo)->sp < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); */
#define MOO_STACK_PUSH(moo,v) \
do { \
(moo)->sp = (moo)->sp + 1; \
MOO_ASSERT (moo, (moo)->sp < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); \
if ((moo)->sp >= (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)) \
{ \
moo_seterrbfmt (moo, MOO_EOOMEM, "process stack overflow"); \
(moo)->abort_req = -1; \
} \
else \
{ \
MOO_STORE_OOP (moo, &(moo)->processor->active->stack[(moo)->sp], v); \
} \
} while(0)
#define MOO_STACK_GET(moo,v_sp) ((moo)->processor->active->stack[v_sp])