RESOLVED FIXED 216062
[JSC] Add missing detached buffer errors for DataView
https://bugs.webkit.org/show_bug.cgi?id=216062
Summary [JSC] Add missing detached buffer errors for DataView
Ross Kirsling
Reported 2020-09-01 18:53:08 PDT
[JSC] Add missing detached buffer errors for ArrayBuffer and DataView
Attachments
Patch (20.39 KB, patch)
2020-09-01 19:00 PDT, Ross Kirsling
no flags
Patch (21.79 KB, patch)
2020-09-01 19:19 PDT, Ross Kirsling
no flags
Patch (39.73 KB, patch)
2020-09-01 20:45 PDT, Ross Kirsling
no flags
Patch for landing (45.10 KB, patch)
2020-09-02 11:52 PDT, Ross Kirsling
no flags
Patch for landing (45.21 KB, patch)
2020-09-02 13:06 PDT, Ross Kirsling
no flags
Patch for landing (30.84 KB, patch)
2020-09-02 18:53 PDT, Ross Kirsling
no flags
Ross Kirsling
Comment 1 2020-09-01 19:00:47 PDT
Ross Kirsling
Comment 2 2020-09-01 19:19:27 PDT
Yusuke Suzuki
Comment 3 2020-09-01 19:37:04 PDT
Comment on attachment 407731 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=407731&action=review r=me with DFG / FTL tests and `DataView.prototype.byteLength` handling in `getOwnPropertySlot` revising. > Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp:74 > + auto* thisObject = jsDynamicCast<JSArrayBuffer*>(vm, callFrame->thisValue()); > + if (!thisObject || thisObject->isShared()) > + return throwVMTypeError(globalObject, scope, "Receiver must be an ArrayBuffer"_s); > + if (thisObject->impl()->isNeutered()) > + return throwVMTypeError(globalObject, scope, "Buffer has already been detached"_s); Can you add a test for DFG / FTL? > Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp:142 > + if (dataView->isNeutered()) > + return throwVMTypeError(globalObject, scope, "Underlying ArrayBuffer has been detached from the view"_s); Can you add a test which works in DFG / FTL? Like this. Because DFG / FTL handles DataView Get / Set functions. function test(dataView){ dataView.getXXX(...); } for (...) test(dataView); detach(dataView); test(dataView); > Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp:197 > + if (dataView->isNeutered()) > + return throwVMTypeError(globalObject, scope, "Underlying ArrayBuffer has been detached from the view"_s); Ditto. > Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h:57 > + auto length = ViewClass::TypedArrayStorageType == TypeDataView ? 1 : 3; We can just put it into the line below. (jsNumber(ViewClass::TypedArrayStorageType == TypeDataView ? 1 : 3)).
Ross Kirsling
Comment 4 2020-09-01 20:45:44 PDT Comment hidden (obsolete)
Ross Kirsling
Comment 5 2020-09-02 11:52:03 PDT
Created attachment 407782 [details] Patch for landing
Ross Kirsling
Comment 6 2020-09-02 11:58:32 PDT
There is a neighboring issue here that DataView's byteLength and byteOffset getters have defined property descriptors: λ eshost -se "JSON.stringify(Object.getOwnPropertyDescriptor(new DataView(new ArrayBuffer(1)), 'byteLength'))" #### ch, sm, v8, xs undefined #### jsc {"value":1,"writable":false,"enumerable":false,"configurable":true} But this is a separate matter from detached buffers and also appears to need test262 cases, so I will handle it separately.
Ross Kirsling
Comment 7 2020-09-02 13:06:01 PDT
Created attachment 407791 [details] Patch for landing
Ross Kirsling
Comment 8 2020-09-02 15:26:58 PDT
Wow, it appears that the ArrayBuffer fix here is actually something that V8 and SM intentionally fail because it's almost certain to break web compatibility (since engines are in agreement). I'll jettison that part of this patch and bring up changing the spec in the next TC39 meeting.
Ross Kirsling
Comment 9 2020-09-02 18:47:16 PDT
(In reply to Ross Kirsling from comment #6) > There is a neighboring issue here that DataView's byteLength and byteOffset > getters have defined property descriptors: > > λ eshost -se "JSON.stringify(Object.getOwnPropertyDescriptor(new > DataView(new ArrayBuffer(1)), 'byteLength'))" > #### ch, sm, v8, xs > undefined > > #### jsc > {"value":1,"writable":false,"enumerable":false,"configurable":true} > > But this is a separate matter from detached buffers and also appears to need > test262 cases, so I will handle it separately. Er rather, this is just as easy to fix as it is to punt on, so I'll address this now and add test262 cases later.
Ross Kirsling
Comment 10 2020-09-02 18:53:59 PDT
Created attachment 407848 [details] Patch for landing
EWS
Comment 11 2020-09-03 10:04:14 PDT
Committed r266529: <https://trac.webkit.org/changeset/266529> All reviewed patches have been landed. Closing bug and clearing flags on attachment 407848 [details].
Radar WebKit Bug Importer
Comment 12 2020-09-03 10:05:16 PDT
Note You need to log in before you can comment on or make changes to this bug.