Fix for segmentation fault when parse_program was called twice with...

Fix for segmentation fault when parse_program was called twice with COMPUTED_GOTOS set (reported in iTasks-SDK#280)
parent 559df0b5
Pipeline #22939 passed with stages
in 14 minutes and 10 seconds
......@@ -329,7 +329,7 @@ void install_interpreter_segv_handler(void) {
}
#ifdef COMPUTED_GOTOS
void *instruction_labels[CMAX];
void *instruction_labels[CMAX]={NULL};
#endif
int interpret(
......
......@@ -201,28 +201,30 @@ int parse_program(struct parser *state, struct char_provider *cp) {
#endif
#ifdef COMPUTED_GOTOS
/* See rationale in interpret.h */
interpret(NULL,
if (instruction_labels[0]==NULL) {
interpret(NULL,
#ifdef LINK_CLEAN_RUNTIME
0,
0,
#endif
NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
for (int i=0; i<32; i++)
Fjmp_ap[i]=(BC_WORD)instruction_labels[Fjmp_ap[i]];
for (int i=0; i<32; i++)
Fjmp_ap[i]=(BC_WORD)instruction_labels[Fjmp_ap[i]];
__interpreter_cycle_in_spine[1] = (void*) instruction_labels[(BC_WORD)__interpreter_cycle_in_spine[1]];
__interpreter_indirection[0] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[0]];
__interpreter_indirection[1] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[1]];
__interpreter_indirection[2] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[2]];
__interpreter_indirection[3] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[3]];
__interpreter_indirection[5] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[5]];
__interpreter_indirection[7] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[7]];
__interpreter_indirection[8] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[8]];
__interpreter_cycle_in_spine[1] = (void*) instruction_labels[(BC_WORD)__interpreter_cycle_in_spine[1]];
__interpreter_indirection[0] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[0]];
__interpreter_indirection[1] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[1]];
__interpreter_indirection[2] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[2]];
__interpreter_indirection[3] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[3]];
__interpreter_indirection[5] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[5]];
__interpreter_indirection[7] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[7]];
__interpreter_indirection[8] = (void*) instruction_labels[(BC_WORD)__interpreter_indirection[8]];
# ifdef LINK_CLEAN_RUNTIME
for (int i = 0; i < 32; i++)
HOST_NODES[i][1] = instruction_labels[Cjsr_eval_host_node+i];
for (int i = 0; i < 32; i++)
HOST_NODES[i][1] = instruction_labels[Cjsr_eval_host_node+i];
# endif
}
#endif
while (state->state != PS_end) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment