bugGNU Common Lisp - Bugs: bug #23977, ansi tests should close open files

 
 

bug #23977: ansi tests should close open files

Submitter:  Sam Steingold <sds>
Submitted:  Fri 01 Aug 2008 06:35:06 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 31 May 2025 02:29:06 PM UTC, comment #2: 

Greetings, thanks for your report, and please excuse the delayed reply.

The READ-SEQUENCE.BV.* tests all close the files they open. 

The
(OPEN "foo.txt" :DIRECTION :OUTPUT :IF-EXISTS :SUPERSEDE)

line is explicitly supposed to handle pre-existing files correctly without error per the spec.

Can you point to any other specific instances you feel are in error?  These two appear valid to me.

Take care,

Camm Maguire <camm>
Group administrator
Fri 01 Aug 2008 06:37:15 PM UTC, comment #1: 

more information:


some ansi tests fail in clisp because a file which is already open for
input and not closed is re-opened for output:

Test READ-BYTE.ERROR.3 failed
Form:
(PROGN
 (LET ((S (OPEN "foo.txt" :DIRECTION :OUTPUT :IF-EXISTS :SUPERSEDE)))
  (CLOSE S))
 (SIGNALS-ERROR
  (LET ((S (OPEN "foo.txt" :DIRECTION :INPUT)))
   (UNWIND-PROTECT (READ-BYTE S) (CLOSE S)))
  ERROR))
Expected value: T
Actual value: OPEN: #<INPUT BUFFERED FILE-STREAM (UNSIGNED-BYTE 8) #P"foo.txt"> already points to file "/homedata/sds/src/clisp/current/build-O/ansi-tests/foo.txt", opening the file again for :OUTPUT may produce unexpected results.
Test READ-BYTE.ERROR.4 failed

it would be nice if you made sure that you close all streams that you
open to avoid these kinds of errors.
this is simply a good programming practice.
also, strictly speaking,
http://www.lispworks.com/documentation/HyperSpec/Body/f_open.htm says:

    "If it is utterly impossible for an implementation to handle some
     option in a manner similar to what is specified here, it may simply
     signal an error"

- and indeed win32 does not allow two processes (let alone the same
process!) to open a file at the same time.


Sam Steingold <sds>
Fri 01 Aug 2008 06:35:06 PM UTC, original submission:  

there are quite a few tests that open files but never explicitly close them (e.g., READ-SEQUENCE.BV.*). 
it would be nice if you used with-open-file instead - both out of "hygienic" consideration and because CLISP detects open file overwrites (see http://www.podval.org/~sds/clisp/impnotes/stream-dict.html#open).

Another issue is that some OSes may limit the total number of open file handles a process may have, so you are thus testing OS and not Lisp.

Sam Steingold <sds>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by camm (Posted a comment)
  • -email is unavailable- added by sds (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.15-e283.
    Corresponding source code