[Ecls-list] ecl_make_stream_from_fd() && smm_io crashes

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sat Mar 20 14:32:56 UTC 2010


On Sat, Mar 20, 2010 at 2:44 PM, Matthew Mondor <mm_lists at pulsar-zone.net>wrote:

> With CVS HEAD ECL, I noticed that if I create a stream over an FD using
> ecl_make_stream_from_fd() in smm_io mode, segmentation faults occur for
> si:file-stream-fd, si::set-buffering-mode as well as read-char.


Most likely fdopen() is failing and the resulting stream is in a bogus
state. I have added an error message to ecl_make_stream_from_fd() to signal
that problem.

A candidate for failure is when you create a file descriptor with one mode
and try to fdopen() it with a different mode, as in the following tiny
example:

(ffi::clines "#include <fcntl.h>")

(defun make-stream (filename)
  (let ((f (namestring filename)))
    (ffi:c-inline (f) (:object) :object "
{
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
cl_object file = #0;
int fd = open(file->base_string.self, O_RDONLY, mode);
printf(\"%d %s\", fd, file->base_string.self);
@(return) = ecl_make_stream_from_fd(file, fd, smm_io,
                                            8, 0, @:default);
}"
                  :one-liner nil)))

Replacing smm_io with smm_input fixes the problem here.

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100320/47da373f/attachment.html>


More information about the ecl-devel mailing list