1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +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
parent ff2adb04cb
commit 9fbb367256
No known key found for this signature in database
GPG key ID: 7CEF29847562C516

View file

@ -1,5 +1,5 @@
/* Copyright (C) 2001, 2009, 2010, 2011, 2012 /* Copyright (C) 2001, 2009, 2010, 2011, 2012
* 2013, 2014, 2015, 2017 Free Software Foundation, Inc. * 2013, 2014, 2015, 2017, 2018 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -341,7 +341,7 @@ process_dynamic_segment (char *base, Elf_Phdr *dyn_phdr,
return NULL; 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 static SCM
load_thunk_from_memory (char *data, size_t len, int is_read_only) load_thunk_from_memory (char *data, size_t len, int is_read_only)
@ -460,7 +460,10 @@ load_thunk_from_memory (char *data, size_t len, int is_read_only)
if ((err_msg = process_dynamic_segment (data, &ph[dynamic_segment], if ((err_msg = process_dynamic_segment (data, &ph[dynamic_segment],
&init, &entry, &frame_maps))) &init, &entry, &frame_maps)))
goto cleanup; {
errno = 0; /* not an OS error */
goto cleanup;
}
if (scm_is_true (init)) if (scm_is_true (init))
scm_call_0 (init); scm_call_0 (init);