From: Kevin Ryde <user42@zip.com.au>
Subject: system* memory leak
Date: Fri, 02 Apr 2004 08:06:29 +1000 [thread overview]
Message-ID: <873c7nwdy2.fsf@zip.com.au> (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
reply other threads:[~2004-04-01 22:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873c7nwdy2.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).