[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Make scm_gc_warn_proc() write directly to stderr
From: |
daniel . llorens |
Subject: |
[PATCH] Make scm_gc_warn_proc() write directly to stderr |
Date: |
Thu, 8 Dec 2016 17:45:12 +0100 |
From: Daniel Llorens <address@hidden>
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.
---
libguile/gc.c | 34 +++-------------------------------
1 file changed, 3 insertions(+), 31 deletions(-)
diff --git a/libguile/gc.c b/libguile/gc.c
index 2b3bd36b0..fc7837c87 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 requires it */
+ fprintf (stderr, fmt, arg);
}
void
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Make scm_gc_warn_proc() write directly to stderr,
daniel . llorens <=