[INTERPRETER]

* BUG: Fix a crash in stack backtrace management.


git-svn-id: svn://localhost/gambas/trunk@4110 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-09-08 22:04:52 +00:00
parent f17878075b
commit 2232c61703
4 changed files with 13 additions and 5 deletions

View file

@ -641,5 +641,5 @@ void ERROR_deprecated(const char *msg)
void ERROR_exit(void)
{
ERROR_reset(&ERROR_last);
FREE(&ERROR_backtrace, "ERROR_exit");
STACK_free_backtrace(&ERROR_backtrace);
}

View file

@ -402,6 +402,7 @@ void DEBUG_print_backtrace(STACK_BACKTRACE *bt)
{
int i, n;
bool stop;
STACK_BACKTRACE *end;
//STACK_CONTEXT *sc = (STACK_CONTEXT *)(STACK_base + STACK_size) - err->bt_count;
//fprintf(stderr, "0: %s\n", DEBUG_get_position(err->cp, err->fp, err->pc));
@ -411,7 +412,8 @@ void DEBUG_print_backtrace(STACK_BACKTRACE *bt)
if (STACK_backtrace_is_end(&bt[i]))
{
stop = TRUE;
STACK_backtrace_remove_end(&bt[i]);
end = &bt[i];
STACK_backtrace_clear_end(end);
}
if (bt[i].pc)
{
@ -419,12 +421,15 @@ void DEBUG_print_backtrace(STACK_BACKTRACE *bt)
fprintf(stderr, "%d: %s\n", n, DEBUG_get_position(bt[i].cp, bt[i].fp, bt[i].pc));
}
}
STACK_backtrace_set_end(end);
}
GB_ARRAY DEBUG_get_string_array_from_backtrace(STACK_BACKTRACE *bt)
{
GB_ARRAY array;
int i, n, size;
STACK_BACKTRACE *end;
for (i = 0, size = 0;; i++)
{
@ -432,7 +437,8 @@ GB_ARRAY DEBUG_get_string_array_from_backtrace(STACK_BACKTRACE *bt)
size++;
if (STACK_backtrace_is_end(&bt[i]))
{
STACK_backtrace_remove_end(&bt[i]);
end = &bt[i];
STACK_backtrace_clear_end(end);
break;
}
}
@ -448,6 +454,7 @@ GB_ARRAY DEBUG_get_string_array_from_backtrace(STACK_BACKTRACE *bt)
n++;
}
STACK_backtrace_set_end(end);
return array;
}

View file

@ -261,7 +261,7 @@ STACK_BACKTRACE *STACK_get_backtrace(void)
// Mark the end of the backtrace
pbt--;
pbt->cp = (void *)(((intptr_t)(pbt->cp)) | 1);
STACK_backtrace_set_end(pbt);
return bt;
}

View file

@ -86,7 +86,8 @@ bool STACK_has_error_handler(void);
STACK_BACKTRACE *STACK_get_backtrace(void);
#define STACK_free_backtrace(_backtrace) FREE(_backtrace, "STRACK_free_backtrace")
#define STACK_backtrace_is_end(_bt) ((((intptr_t)((_bt)->cp)) & 1) != 0)
#define STACK_backtrace_remove_end(_bt) ((_bt)->cp = (void *)(((intptr_t)((_bt)->cp)) & ~1))
#define STACK_backtrace_set_end(_bt) ((_bt)->cp = (void *)(((intptr_t)((_bt)->cp)) | 1))
#define STACK_backtrace_clear_end(_bt) ((_bt)->cp = (void *)(((intptr_t)((_bt)->cp)) & ~1))
STACK_CONTEXT *STACK_get_frame(int frame);