file-position returns zero for file opened for append

Bug #561642 reported by Dave Adam on 2010-04-12
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

The following test case should work with any file. This is the first test case I grabbed.

(with-open-file (stream "INSTALL" :direction :output :if-exists :append)
     (values (file-position stream) (file-length stream )))

In case it helps, the really confusing part is that it corrects itself after a few writes. The few I just checked corrected file-position after 18 - 44 writes. Then for the next few hundred it was correct.

Version: SBCL 1.0.37

uname -a
Darwin Macintosh.local 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386

However, this bug was first discovered on Linux.


Changed in sbcl:
status: New → Triaged
importance: Undecided → Medium

The attached patch fixes this bug.

This can also be pulled from

Nikodemus Siivola (nikodemus) wrote :

William, when adding a patch, it's a good idea to also add a "review" tag.

tags: added: review
Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: Triaged → In Progress
Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Nikodemus Siivola (nikodemus) wrote :

commit b021c15b8d8e4ea4740323eaee9535c4e7cb2232
Author: William Halliburton <email address hidden>
Date: Sun Feb 13 12:01:17 2011 -0700


      For O_APPEND opened files, lseek returns 0 until first write.
      So we jump ahead initially.


Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers