Commit 5fafa40d authored by Paul Eggert's avatar Paul Eggert

Improve checking of pdump load failures

* src/alloc.c (memory_full): Just report "memory exhausted" if
failure occurs during initialization, since fancier recovery
schemes are not likely to work when not initialized.
* src/emacs.c (dump_error_to_string): Accept int, not enum
pdumper_load_result, since the result might not fit in the
enum.  Use strerror if it was derived from errno.  This is for
better diagnostics of pdump load failures.
(load_pdump_find_executable): Return char *, not enum.  2nd
arg is now pointer to buffer size, rather than pointer to
pointer to buffer.  All callers changed.  Use Emacs allocator
since they should now be OK even during early startup.
Use check_executable instead access, to use effective rather
than real permissions.
(load_pdump): Return void since callers ignore result.
Use int where enum could be too narrow.  Use heap rather
than stack for possibly-long string.  Prefer ptrdiff_t to
* src/fileio.c (check_executable): Now extern.
* src/pdumper.c (pdumper_load): Return int that may have
errno added to it, for better diagnostics when loads fail.
parent a6daae7b
Pipeline #3099 failed with stage
in 54 minutes and 56 seconds
......@@ -3844,6 +3844,9 @@ set_interval_marked (INTERVAL i)
memory_full (size_t nbytes)
if (!initialized)
fatal ("memory exhausted");
/* Do not go into hysterics merely because a large request failed. */
bool enough_free_memory = false;
if (SPARE_MEMORY < nbytes)
This diff is collapsed.
......@@ -150,7 +150,7 @@ check_existing (const char *filename)
/* Return true if file FILENAME exists and can be executed. */
static bool
check_executable (char *filename)
return faccessat (AT_FDCWD, filename, X_OK, AT_EACCESS) == 0;
......@@ -4298,6 +4298,7 @@ extern void syms_of_marker (void);
/* Defined in fileio.c. */
extern bool check_executable (char *);
extern char *splice_dir_file (char *, char const *, char const *);
extern bool file_name_absolute_p (const char *);
extern char const *get_homedir (void);
......@@ -5303,7 +5303,7 @@ enum dump_section
N.B. We run very early in initialization, so we can't use lisp,
unwinding, xmalloc, and so on. */
enum pdumper_load_result
pdumper_load (const char *dump_filename)
intptr_t dump_size;
......@@ -5328,10 +5328,15 @@ pdumper_load (const char *dump_filename)
/* We can load only one dump. */
eassert (!dump_loaded_p ());
enum pdumper_load_result err = PDUMPER_LOAD_FILE_NOT_FOUND;
int err;
int dump_fd = emacs_open (dump_filename, O_RDONLY, 0);
if (dump_fd < 0)
goto out;
err = (errno == ENOENT || errno == ENOTDIR
goto out;
if (fstat (dump_fd, &stat) < 0)
......@@ -124,10 +124,10 @@ enum pdumper_load_result
PDUMPER_LOAD_ERROR /* Must be last, as errno may be added. */
enum pdumper_load_result pdumper_load (const char *dump_filename);
int pdumper_load (const char *dump_filename);
struct pdumper_loaded_dump
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