[Top][All Lists]

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

Re: sigaction leak

From: Marius Vollmer
Subject: Re: sigaction leak
Date: Tue, 11 May 2004 00:14:19 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> On my i386 debian, a program
>       (while #t (sigaction SIGPIPE (sigaction SIGPIPE SIG_IGN)))
> seems to make the guile process grow without bound, not very quickly,
> but apparently inexorably.

Got it!  The code above uses sigaction incorrectly, it should be
something like

    (define (restore-sigaction num old)
      (sigaction num (car old) (cdr old)))

    (while #t (restore-sigaction SIGPIPE (sigaction SIGPIPE SIG_IGN)))

The 'leak' occurs because the outer sigaction stores a larger and
larger data structure as the handler of the signal.  That data
structure is not a valid handler, but sigaction doesn't reject it.

    guile> (define old (sigaction SIGPIPE SIG_IGN))
    guile> old
    (0 . 268435456)
    guile> (sigaction SIGPIPE old)
    (1 . 268435456)
    guile> (define old (sigaction SIGPIPE SIG_IGN))
    guile> old
    ((0 . 268435456) . 268435456)

I have fixed sigaction:

2004-05-11  Marius Vollmer  <address@hidden>

        * scmsigs.c (scm_sigaction_for_thread): Validate that the handler
        is indeed a procedure when it isn't a number.

GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

reply via email to

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