Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"get a copy of the bytes held by the buffer source" should not fail for detached buffers #151

Closed
annevk opened this issue Aug 24, 2016 · 5 comments
Labels
☕☕ difficulty:medium Hard to fix ⌛⌛⌛ duration:long There goes your week-end

Comments

@annevk
Copy link
Member

annevk commented Aug 24, 2016

Currently it seems that IDL throws for detached buffers. However, as far as I can tell implementations do not follow this and simply end up with the empty byte sequence whenever they encounter a detached buffer.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4414 is my demo for this (note the lack of exceptions/rejections).

(Note that there's also still an ask to clean up this aspect of IDL and make it much easier to work with: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28798 .)

@bzbarsky
Copy link
Collaborator

Note that I think this may be a more general issue, in that the ES spec requires throwing in many cases when operating on detached stuff, but in practice UAs don't do that... Worth checking with @jswalden at least; I recall him doing some work on that stuff.

@annevk
Copy link
Member Author

annevk commented Aug 24, 2016

Yeah, I raised that two years ago when I last did research into this: https://esdiscuss.org/topic/arraybuffer-neutering. @bterlson is TC39 still hoping implementers will throw more for ArrayBuffer and friends? When are we going to throw in the towel?

@annevk
Copy link
Member Author

annevk commented Aug 24, 2016

In any event, IDL doesn't have to follow suit and can just return the empty byte sequence if IsDetached returns true solving at least part of the problem.

@bterlson
Copy link

I think we hope everyone will align and throw more often, but I admit that I haven't looked into this area for at least a year so things may have changed. There should be test262 collateral for all this (right, @tcare / @leobalter / @jugglinmike?) so I think it's just a matter of priorities. Hopefully the web doesn't depend on non-throwing behavior? (Seems likely given that detached buffers aren't very common, I suppose)

@littledan
Copy link
Collaborator

test262 does include tests for this (thanks @leobalter) but I'm still concerned about web compatibility. I haven't figured out how to instrument TypedArrays to measure whether detached TypedArrays are ever accessed without decreasing TypedArray performance (we set the length to 0 and bounds checks handle accesses, so we don't need a separate detached check), so I'm not sure how to get the information from telemetry. Does anyone else have an idea for how to get solid data on this question?

@tobie tobie added ⌛⌛⌛ duration:long There goes your week-end ☕☕ difficulty:medium Hard to fix labels Sep 5, 2016
annevk added a commit that referenced this issue Jan 9, 2019
As far as I can tell there's no way for a %TypedArray%'s [[ViewedArrayBuffer]] internal slot to be undefined. I'm pretty sure this has to be the case as implementations assume this algorithm to never throw (the detached issue is tracked separately by #151).
annevk added a commit that referenced this issue Jan 9, 2019
Instead treat them the same as the empty byte sequence as implementations have been doing since forever.

This also performs the IsDetachedBuffer abstract operation on the correct object.

Fixes #151.
annevk added a commit that referenced this issue Jan 9, 2019
As far as I can tell there's no way for a %TypedArray%'s [[ViewedArrayBuffer]] internal slot to be undefined. I'm pretty sure this has to be the case as implementations assume this algorithm to never throw (the detached issue is tracked separately by #151).
annevk added a commit that referenced this issue Jan 10, 2019
Instead treat them the same as the empty byte sequence as implementations have been doing since forever.

This also performs the IsDetachedBuffer abstract operation on the correct object.

Fixes #151.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☕☕ difficulty:medium Hard to fix ⌛⌛⌛ duration:long There goes your week-end
Development

No branches or pull requests

5 participants