-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Broken in Chrome 49.0.2620.0 canary (64-bit) #94
Comments
No, 5f5478a was just changing Safari 5-7 to use the typed array implementation. It sounds like Chrome broke something in Canary. I opened an issue on the V8 tracker so we can fix this before this makes it farther in the release cycle. https://bugs.chromium.org/p/v8/issues/detail?id=4665 |
Hehe, that is some timing though 😆 The output of this script in the above stated version of Chrome alerts function typedArraySupportBroken () {
function Bar () {}
try {
var arr = new Uint8Array(1)
arr.foo = function () { return 42 }
arr.constructor = Bar
return arr.foo() === 42 && // typed array instances can be augmented
arr.constructor === Bar && // constructor can be set
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
function typedArraySupportWorks () {
try {
var arr = new Uint8Array(1)
arr.foo = function () { return 42 }
return arr.foo() === 42 && // typed array instances can be augmented
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
alert(typedArraySupportBroken())
alert(typedArraySupportWorks()) Conclusion: The |
It's actually throwing the exception on Crazy timing. |
Actually, the tests aren't failing because Here's a simple test case to repro: function Buffer (arg) {
var arr = new Uint8Array(arg)
arr.__proto__ = Buffer.prototype
return arr
}
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
var buf = new Buffer(10)
var buf2 = buf.subarray(2)
console.log(buf2.length) // returns 10 in Canary, instead of 8 as expected |
That's true, I must have missed typing out the end of that sentence :) Hopefully this will get fixed sooner rather than later in Chrome and than we won't need to do anything at all here... |
Yeah, I think let's wait a couple days. If there's no indication they plan to fix it in Chrome in a timely manner, we can do a new release with your PR and add a big TODO to the code to remove that as soon as possible. |
This has already been fixed in Chrome Canary. Thanks for the bug report. |
Closing based on #95 (comment) |
My chrome updated during the night and now my stuff doesn't work anymore, fun times, I get to debug!
The first thing was actually already fixed by 5f5478a, I just had to update to the latest version. @feross Was that commit intentionally fixing a Chrome bug?
The next problem is that
.subarray(start, end)
seems broken when the__proto__
is tampered with.The following code fixes the problem but I'm not sure that it's the right approach:
The text was updated successfully, but these errors were encountered: