mirror of
https://github.com/janet-lang/janet
synced 2025-02-08 21:10:02 +00:00
Add per fiber stack limit.
This commit is contained in:
parent
a614816a04
commit
2f4fd23884
@ -37,6 +37,7 @@ DstFiber *dst_fiber(int32_t capacity) {
|
|||||||
fiber->data = NULL;
|
fiber->data = NULL;
|
||||||
}
|
}
|
||||||
fiber->parent = NULL;
|
fiber->parent = NULL;
|
||||||
|
fiber->maxstack = DST_STACK_MAX;
|
||||||
return dst_fiber_reset(fiber);
|
return dst_fiber_reset(fiber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,11 +572,10 @@ static void *op_lookup[255] = {
|
|||||||
VM_OP(DOP_CALL)
|
VM_OP(DOP_CALL)
|
||||||
{
|
{
|
||||||
Dst callee = stack[oparg(2, 0xFFFF)];
|
Dst callee = stack[oparg(2, 0xFFFF)];
|
||||||
#ifdef DST_STACK_MAX
|
if (dst_vm_fiber->maxstack &&
|
||||||
if (dst_vm_fiber->stacktop > DST_STACK_MAX) {
|
dst_vm_fiber->stacktop > dst_vm_fiber->maxstack) {
|
||||||
vm_throw("stack overflow");
|
vm_throw("stack overflow");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (dst_checktype(callee, DST_FUNCTION)) {
|
if (dst_checktype(callee, DST_FUNCTION)) {
|
||||||
func = dst_unwrap_function(callee);
|
func = dst_unwrap_function(callee);
|
||||||
dst_stack_frame(stack)->pc = pc;
|
dst_stack_frame(stack)->pc = pc;
|
||||||
|
@ -123,7 +123,7 @@ extern "C" {
|
|||||||
/* Define max stack size for stacks before raising a stack overflow error.
|
/* Define max stack size for stacks before raising a stack overflow error.
|
||||||
* If this is not defined, fiber stacks can grow without limit (until memory
|
* If this is not defined, fiber stacks can grow without limit (until memory
|
||||||
* runs out) */
|
* runs out) */
|
||||||
#define DST_STACK_MAX 4096
|
#define DST_STACK_MAX 8192
|
||||||
|
|
||||||
/* Use nanboxed values - uses 8 bytes per value instead of 12 or 16. */
|
/* Use nanboxed values - uses 8 bytes per value instead of 12 or 16. */
|
||||||
#define DST_NANBOX
|
#define DST_NANBOX
|
||||||
|
@ -314,6 +314,7 @@ struct DstFiber {
|
|||||||
int32_t stackstart; /* Beginning of next args */
|
int32_t stackstart; /* Beginning of next args */
|
||||||
int32_t stacktop; /* Top of stack. Where values are pushed and popped from. */
|
int32_t stacktop; /* Top of stack. Where values are pushed and popped from. */
|
||||||
int32_t capacity;
|
int32_t capacity;
|
||||||
|
int32_t maxstack; /* Arbitrary defined limit for stack overflow */
|
||||||
enum {
|
enum {
|
||||||
DST_FIBER_PENDING,
|
DST_FIBER_PENDING,
|
||||||
DST_FIBER_NEW,
|
DST_FIBER_NEW,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user