unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* system* memory leak
@ 2004-04-01 22:06 Kevin Ryde
  0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2004-04-01 22:06 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

        * simpos.c (scm_system_star): Fix execargv memory leak.

This occurs on any invocation, eg.

	(while #t (system* "true"))

The diff is bigger than it might be since I rearranged to combine the
parent and fork-error cases.

This is definitely a leak, but there seems to be a further problem
with sigaction afflicting system*, see other message.


[-- Attachment #2: simpos.c.leak.diff --]
[-- Type: text/plain, Size: 1450 bytes --]

--- simpos.c.~1.55.~	2004-03-31 11:57:03.000000000 +1000
+++ simpos.c	2004-04-01 07:09:02.000000000 +1000
@@ -158,12 +158,26 @@
       oldquit = scm_sigaction (sigquit, sig_ign, SCM_UNDEFINED);
       
       pid = fork ();
-      if (pid == -1)
-        SCM_SYSERROR;
-      else if (pid)
+      if (pid == 0)
         {
-          int wait_result;
-          int status;
+          /* child */
+          execvp (SCM_STRING_CHARS (SCM_CAR (args)), execargv);
+          scm_remember_upto_here_1 (args);
+          SCM_SYSERROR;
+          /* not reached.  */
+          return SCM_BOOL_F;
+        }
+      else
+        {
+          /* parent */
+          int wait_result, status, save_errno;
+
+          save_errno = errno;
+          free (execargv);
+          errno = save_errno;
+          if (pid == -1)
+            SCM_SYSERROR;
+
           SCM_SYSCALL (wait_result = waitpid (pid, &status, 0));
           if (wait_result == -1) SCM_SYSERROR;
           scm_sigaction (sigint, SCM_CAR (oldint), SCM_CDR (oldint));
@@ -171,14 +185,6 @@
           scm_remember_upto_here_2 (oldint, oldquit);
           return SCM_MAKINUM (0L + status);
         }
-      else
-        {
-          execvp (SCM_STRING_CHARS (SCM_CAR (args)), execargv);
-          scm_remember_upto_here_1 (args);
-          SCM_SYSERROR;
-          /* not reached.  */
-          return SCM_BOOL_F;
-        }
     }
   else
     SCM_WRONG_TYPE_ARG (1, SCM_CAR (args));

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-01 22:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-01 22:06 system* memory leak Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).