CLOSE :ABORT T on superseding streams

Bug #309091 reported by Nikodemus Siivola
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Confirmed
Wishlist
Unassigned

Bug Description

Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
file on disk, even if one existed before opening.

The illegality of this is not crystal clear, as the ANSI dictionary
entry for CLOSE says that when :ABORT is T superseded files are not
superseded (ie. the original should be restored), whereas the OPEN
entry says about :IF-EXISTS :SUPERSEDE "If possible, the
implementation should not destroy the old file until the new stream
is closed." -- implying that even though undesirable, early deletion
is legal. Restoring the original would none the less be the polite
thing to do.

Note: Richard Kreuter's "transaction stream" proposal (sbcl-devel link goes here)
would be one way to address this, and other related issues.

Tags: streams
description: updated
Changed in sbcl:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Tomas Hlavaty (tomas-hlavaty) wrote :

simple test case (works as expected on ccl and allegro):

(let ((fname "/tmp/a"))
  ;; touch
  (with-open-file (s fname :direction :output :if-exists :supersede)
    (format s "hello~%"))
  ;; supersede
  (catch 'hi
    (with-open-file (s fname :direction :output :if-exists :supersede)
      (format s "hi~%")
      (throw 'hi nil)))
  ;; check still exists
  (assert (probe-file fname)) ;; <=== it was deleted:-{
  (with-open-file (s fname)
    (assert (equal "hello" (read-line s)))
    t))

Revision history for this message
Pierre Neidhardt (ambrevar) wrote :

I was bitten by this as well.

Has there been any progress ever since?

The original post mentions a "transaction stream" proposal, has it been merged?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.