unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Martin Ward <martin@gkc.org.uk>
Cc: bug-guile@gnu.org, Mike Gran <spk121@yahoo.com>
Subject: Re: Guile 2.0.0 cannot open /dev/urandom
Date: Sun, 27 Feb 2011 23:47:33 +0100	[thread overview]
Message-ID: <m362s5rt6i.fsf@unquote.localdomain> (raw)
In-Reply-To: <201102172258.33666.martin@gkc.org.uk> (Martin Ward's message of "Thu, 17 Feb 2011 22:58:33 +0000")

Hi Martin,

On Thu 17 Feb 2011 23:58, Martin Ward <martin@gkc.org.uk> writes:

> scheme@(guile-user)> (open-input-file "/dev/urandom")
> ERROR: In procedure open-file:
> ERROR: In procedure fport_end_input: Invalid argument

Good catch!

The relevant part of the C backtrace is:

    #22 0x00007ffff7cd83f6 in scm_syserror (subr=0x7ffff7d8008e "fport_end_input") at error.c:177
    #23 0x00007ffff7ce174c in fport_end_input (port=<value optimized out>, offset=<value optimized out>) at fports.c:838
    #24 0x00007ffff7ce1817 in fport_seek (port=<value optimized out>, offset=<value optimized out>, 
        whence=<value optimized out>) at fports.c:709
    #25 0x00007ffff7d13d65 in scm_seek (fd_port=0x118cec0, offset=0x2, whence=<value optimized out>) at ports.c:1768
    #26 0x00007ffff7d1f5a9 in scm_i_scan_for_encoding (port=0x118cec0) at read.c:1672
    #27 0x00007ffff7ce250b in scm_open_file (filename=0x11659e0, mode=0x7676c0) at fports.c:463

It seems that Guile is scanning the first few lines of the file for a
"coding" declaration.  This is because it is being opened in textual
mode; if you open with (open-file "/dev/urandom" "rb") you will probably
get what you want.

It should not be erroring out here.  In fact the error appears to
proceed from an attempt to seek in the port after reading out the first
N bytes to scan them for a coding directive; hummm.  Mike, it seems that
we should unget bytes onto the port instead of seeking; does that sound
right to you?

Martin, note that with Guile 1.8 and earlier, byte IO masquerading as
character IO was all you have.  Now with 2.0 you really want to be
dealing with binary ports and bytevectors and such.

Thanks for the report,

Andy
-- 
http://wingolog.org/



  parent reply	other threads:[~2011-02-27 22:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 22:58 Guile 2.0.0 cannot open /dev/urandom Martin Ward
2011-02-18  4:44 ` Mark Harig
2011-02-27 22:47 ` Andy Wingo [this message]
2011-03-03 11:57   ` Andy Wingo

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=m362s5rt6i.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=bug-guile@gnu.org \
    --cc=martin@gkc.org.uk \
    --cc=spk121@yahoo.com \
    /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).