mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 09:17:17 +00:00
Fix pointer incorrect pointer manipulation that happened
to work on a x86-64
This commit is contained in:
parent
3c9aae3a63
commit
f860b950fc
@ -26,6 +26,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
|
#include "fiber.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
jmp_buf err;
|
jmp_buf err;
|
||||||
@ -261,9 +262,9 @@ static void marshal_one_fiber(MarshalState *st, JanetFiber *fiber, int flags) {
|
|||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
JanetStackFrame *frame = (JanetStackFrame *)(fiber->data + i - JANET_FRAME_SIZE);
|
JanetStackFrame *frame = (JanetStackFrame *)(fiber->data + i - JANET_FRAME_SIZE);
|
||||||
if (frame->env) frame->flags |= JANET_STACKFRAME_HASENV;
|
if (frame->env) frame->flags |= JANET_STACKFRAME_HASENV;
|
||||||
|
if (!frame->func) longjmp(st->err, MR_C_STACKFRAME);
|
||||||
pushint(st, frame->flags);
|
pushint(st, frame->flags);
|
||||||
pushint(st, frame->prevframe);
|
pushint(st, frame->prevframe);
|
||||||
if (!frame->func) longjmp(st->err, MR_C_STACKFRAME);
|
|
||||||
int32_t pcdiff = frame->pc - frame->func->def->bytecode;
|
int32_t pcdiff = frame->pc - frame->func->def->bytecode;
|
||||||
pushint(st, pcdiff);
|
pushint(st, pcdiff);
|
||||||
marshal_one(st, janet_wrap_function(frame->func), flags + 1);
|
marshal_one(st, janet_wrap_function(frame->func), flags + 1);
|
||||||
@ -769,6 +770,8 @@ static const uint8_t *unmarshal_one_fiber(
|
|||||||
fiber->stackstart = 0;
|
fiber->stackstart = 0;
|
||||||
fiber->stacktop = 0;
|
fiber->stacktop = 0;
|
||||||
fiber->capacity = 0;
|
fiber->capacity = 0;
|
||||||
|
fiber->maxstack = 0;
|
||||||
|
fiber->data = NULL;
|
||||||
fiber->child = NULL;
|
fiber->child = NULL;
|
||||||
|
|
||||||
/* Set frame later so fiber can be GCed at anytime if unmarshaling fails */
|
/* Set frame later so fiber can be GCed at anytime if unmarshaling fails */
|
||||||
@ -802,8 +805,8 @@ static const uint8_t *unmarshal_one_fiber(
|
|||||||
stack = frame;
|
stack = frame;
|
||||||
stacktop = fiber->stackstart - JANET_FRAME_SIZE;
|
stacktop = fiber->stackstart - JANET_FRAME_SIZE;
|
||||||
while (stack > 0) {
|
while (stack > 0) {
|
||||||
JanetFunction *func;
|
JanetFunction *func = NULL;
|
||||||
JanetFuncDef *def;
|
JanetFuncDef *def = NULL;
|
||||||
JanetFuncEnv *env = NULL;
|
JanetFuncEnv *env = NULL;
|
||||||
int32_t frameflags = readint(st, &data);
|
int32_t frameflags = readint(st, &data);
|
||||||
int32_t prevframe = readint(st, &data);
|
int32_t prevframe = readint(st, &data);
|
||||||
@ -811,7 +814,7 @@ static const uint8_t *unmarshal_one_fiber(
|
|||||||
|
|
||||||
/* Get frame items */
|
/* Get frame items */
|
||||||
Janet *framestack = fiber->data + stack;
|
Janet *framestack = fiber->data + stack;
|
||||||
JanetStackFrame *framep = (JanetStackFrame *)framestack - 1;
|
JanetStackFrame *framep = janet_stack_frame(framestack);
|
||||||
|
|
||||||
/* Get function */
|
/* Get function */
|
||||||
Janet funcv;
|
Janet funcv;
|
||||||
|
Loading…
Reference in New Issue
Block a user