chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATCH] Scrutiny type for signal-handler wrong


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Scrutiny type for signal-handler wrong
Date: Sat, 6 Oct 2012 18:28:22 +0200
User-agent: Mutt/1.4.2.3i

Hi all,

I noticed that compiling scsh-process with "standard-extension" caused
it to consistently segfault.  Turns out that the type entry for
signal-handler is wrong; it is declared to return a procedure always,
but it may return #f when no handler is installed yet.  This causes
the scrutinizer to eliminate the WHEN check in the following code:

(use posix)

(set-signal-handler!
   signal/chld
   (let ((old-handler (signal-handler signal/chld)))
     (lambda (signal)
       (print "Got " signal ", old-handler is " old-handler)
       (when old-handler (print "Calling old-handler(!)") (old-handler 
signal)))))

(process-fork (lambda () (print "child")))
(sleep 1)
(print "parent")

$ csc -O3 test.scm
[...]
$ ./test
child
Got 20, old-handler is #f
Calling old-handler(!)
zsh: segmentation fault  ./test

Attached is a fix.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: 0001-Fixed-scrutiny-db-type-entry-for-signal-handler-it-w.patch
Description: Text document


reply via email to

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