Closed Bug 1122788 Opened 11 years ago Closed 10 years ago

Incorrect behavior of DOM File access to deleted files on debug builds

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: jld, Assigned: baku)

References

Details

Attachments

(2 files)

If a DOM File is constructed for a file that is later deleted, trying to read it will invoke the reader's onerror handler, except on debug builds. On debug builds, the routine SeekableStreamAtBeginning in xpcom/io/nsMultiplexInputStream.cpp will call the Tell() method on the input stream, which performs its deferred open, but SeekableStreamAtBeginning discards the error from that method. I ran into this in bug 1068838 while trying to adjust dom/base/test/test_fileapi.html to use the File constructor (in a chrome script) instead of writing to a file input element's |value| property and opening files directly; this may be related to how those two paths use different BlobImpls. It's possible that this bug belongs in XPCOM instead of DOM; adjust as needed.
Blocks: 1198095
Attached patch fix.patchSplinter Review
I didn't find any reasonable way to fix this blocker for bug 1198095. Another approach would be to change the nsTArray of nsIInputStream in some data struct with a boolean and then the first time we use this particular nsIInputStream, we check if the Tell() returns 0, but that will increase the level of complexity, almost for nothing.
Attachment #8695902 - Flags: review?(bzbarsky)
Comment on attachment 8695902 [details] [diff] [review] fix.patch We could try skipping the tell() for file streams in particular, but we may have a buffered file stream which would have the same problem... r=me, I guess.
Attachment #8695902 - Flags: review?(bzbarsky) → review+
Assignee: nobody → amarchesini
Attached patch e10sSplinter Review
For e10s we must propagate the error code from Available. The reason why this is needed, is that, here: http://mxr.mozilla.org/mozilla-central/source/dom/ipc/Blob.cpp#1626 we use Available() to force the stream open, but if this fails, in: http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsMultiplexInputStream.cpp#725 we don't propagate such error value to the child process. Probably would be a good idea to update mStatus for each public nsMultiplexInputStream method.
Flags: needinfo?(amarchesini)
Attachment #8696155 - Flags: review?(bzbarsky)
Attachment #8696155 - Flags: review?(bzbarsky) → review+
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: