diff options
author | Andy Wingo <wingo@pobox.com> | 2019-11-25 09:46:13 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-11-25 09:46:58 +0100 |
commit | 2fbc38f0d08f00632c063139b750d6976bf5499b (patch) | |
tree | 58ecd59dcf64e532759cfd6bed5a0809004fb9ed /libguile/throw.c | |
parent | a12e862beccd8172d3b04f6ca0e633837491f4d4 (diff) | |
download | guile-2fbc38f0d08f00632c063139b750d6976bf5499b.tar.gz |
Fix stack overflow if printing a pre-boot error throws an error
* libguile/throw.c (scm_throw): Fall back to fprintf if all is lost.
Diffstat (limited to 'libguile/throw.c')
-rw-r--r-- | libguile/throw.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libguile/throw.c b/libguile/throw.c index 9c89c6511..e837abe89 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -243,11 +243,20 @@ scm_throw (SCM key, SCM args) { SCM throw = scm_variable_ref (throw_var); if (scm_is_false (throw)) { - SCM port = scm_current_error_port (); - scm_puts ("Pre-boot error; key: ", port); - scm_write (key, port); - scm_puts (", args: ", port); - scm_write (args, port); + static int error_printing_error = 0; + if (error_printing_error++) + { + fprintf (stderr, "Error while printing pre-boot error: %s\n", + scm_i_symbol_chars (key)); + } + else + { + SCM port = scm_current_error_port (); + scm_puts ("Pre-boot error; key: ", port); + scm_write (key, port); + scm_puts (", args: ", port); + scm_write (args, port); + } abort (); } scm_apply_1 (throw, key, args); |