1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Fix error reporting in 'load-thunk-from-memory'.

Previously 'load-thunk-from-memory' would often throw to 'system-error'
based on a stale value in 'errno', leading to incorrect error messages.

* libguile/loader.c (load_thunk_from_memory): Set 'errno' to 0 before
jumping to cleanup in the ABORT preprocessor macro, and also in the case
when 'process_dynamic_segment' reports an error.
This commit is contained in:
Mark H Weaver 2018-06-11 01:06:34 -04:00 committed by Andy Wingo
parent 9fd1dc2fcc
commit a44c2a679f

View file

@ -348,7 +348,7 @@ process_dynamic_segment (char *base, Elf_Phdr *dyn_phdr,
return NULL;
}
#define ABORT(msg) do { err_msg = msg; goto cleanup; } while (0)
#define ABORT(msg) do { err_msg = msg; errno = 0; goto cleanup; } while (0)
static SCM
load_thunk_from_memory (char *data, size_t len, int is_read_only)
@ -469,7 +469,10 @@ load_thunk_from_memory (char *data, size_t len, int is_read_only)
if ((err_msg = process_dynamic_segment (data, &ph[dynamic_segment],
&init, &entry, &frame_maps)))
{
errno = 0; /* not an OS error */
goto cleanup;
}
if (scm_is_true (init))
scm_call_0 (init);