[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #999: Unit ports uses read-string! from unit extras,
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #999: Unit ports uses read-string! from unit extras, causing errors (segfaults) in programs that only (use ports) |
Date: |
Sun, 17 Mar 2013 20:16:16 -0000 |
#999: Unit ports uses read-string! from unit extras, causing errors (segfaults)
in programs that only (use ports)
----------------------------+-----------------------------------------------
Reporter: sjamaan | Owner: felix
Type: defect | Status: new
Priority: major | Milestone: someday
Component: core libraries | Version: 4.8.x
Keywords: |
----------------------------+-----------------------------------------------
On IRC, user "szablica" pointed out that the following program will cause
a segfault when run in compiled mode:
{{{
#!scm
(use ports)
(define (read-file-contents filename)
(call-with-output-string
(lambda (result-string)
(call-with-input-file
filename
(lambda (source-file)
(copy-port source-file result-string))))))
(display (read-file-contents "/etc/hosts"))
}}}
If you run it with a Chicken built with DEBUGBUILD=1, you'll get a decent
error message:
{{{
Error: unbound variable: read-string!
Call history:
foo.scm:11: read-file-contents
foo.scm:4: call-with-output-string
foo.scm:6: call-with-input-file
foo.scm:9: copy-port <--
}}}
It works fine from csi. The reason this doesn't work is that {{{read-
string!}}} is provded by unit extras, but ports doesn't depend on it.
Simply adding {{{(uses extras)}}} to the declarations causes the problem
to go away, but AFAICT, this is iffy: extras already declares {{{(uses
ports)}}} so this would mean we've introduced a circular dependency.
I think such implicit dependencies could be easily prevented by converting
core to use proper modules, and getting rid of the "unit" concept, but I
don't know if that's feasible.
--
Ticket URL: <http://bugs.call-cc.org/ticket/999>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #999: Unit ports uses read-string! from unit extras, causing errors (segfaults) in programs that only (use ports),
Chicken Trac <=