diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2016-12-08 17:40:12 +0100 |
---|---|---|
committer | Daniel Llorens <daniel.llorens@bluewin.ch> | 2016-12-14 09:49:52 +0100 |
commit | 37551e40b8fd2708a43759904d347a5281675d85 (patch) | |
tree | a0da2f50a515db70e29c6f31289843fb4101896d | |
parent | 6dd87f4d8c764360c8d22c03f65603ea8b8c9e78 (diff) |
Make scm_gc_warn_proc() write directly to stderr
This avoids a deadlock due to the lookup of cur_warnport_fluid while an
allocation is ongoing.
* libguile/gc.c (scm_gc_warn_proc): Write the warning directly to
stderr.
-rw-r--r-- | libguile/gc.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/libguile/gc.c b/libguile/gc.c index 648c678d6..4478128c6 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -105,37 +105,9 @@ scm_oom_fn (size_t nbytes) static void scm_gc_warn_proc (char *fmt, GC_word arg) { - SCM port; - FILE *stream = NULL; - - port = scm_current_warning_port (); - if (!SCM_OPPORTP (port)) - return; - - if (SCM_FPORTP (port)) - { - int fd; - scm_force_output (port); - if (!SCM_OPPORTP (port)) - return; - fd = dup (SCM_FPORT_FDES (port)); - if (fd == -1) - perror ("Failed to dup warning port fd"); - else - { - stream = fdopen (fd, "a"); - if (!stream) - { - perror ("Failed to open stream for warning port"); - close (fd); - } - } - } - - fprintf (stream ? stream : stderr, fmt, arg); - - if (stream) - fclose (stream); + /* avoid scm_current_warning_port() b/c the GC lock is already taken + and the fluid ref might require it */ + fprintf (stderr, fmt, arg); } void |