guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/01: Make scm_gc_warn_proc() write directly to stderr


From: Daniel Llorens
Subject: [Guile-commits] 01/01: Make scm_gc_warn_proc() write directly to stderr
Date: Wed, 14 Dec 2016 08:56:54 +0000 (UTC)

lloda pushed a commit to branch master
in repository guile.

commit 37551e40b8fd2708a43759904d347a5281675d85
Author: Daniel Llorens <address@hidden>
Date:   Thu Dec 8 17:40:12 2016 +0100

    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.
---
 libguile/gc.c |   34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/libguile/gc.c b/libguile/gc.c
index 648c678..4478128 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]