RESOLVED FIXED 163899
WebAssembly API: test with neutered inputs
https://bugs.webkit.org/show_bug.cgi?id=163899
Summary WebAssembly API: test with neutered inputs
JF Bastien
Reported 2016-10-24 10:29:32 PDT
The TypedArray and Views passed to the WebAssembly APIs can be neutered. I'm adding basic checks for this but am being lazy in testing them for now, just leaving TODOs for now. I need to go back and fix this, and clarify what exception type needs to be thrown (TypeError seems to be what JS uses elsewhere).
Attachments
Patch (120.01 KB, patch)
2017-05-15 23:06 PDT, Keith Miller
no flags
Patch (121.79 KB, patch)
2017-05-16 00:18 PDT, Keith Miller
no flags
Patch for landing (121.79 KB, patch)
2017-05-16 00:19 PDT, Keith Miller
no flags
Archive of layout-test-results from ews103 for mac-elcapitan (1.03 MB, application/zip)
2017-05-16 01:42 PDT, Build Bot
no flags
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (951.00 KB, application/zip)
2017-05-16 01:48 PDT, Build Bot
no flags
Archive of layout-test-results from ews112 for mac-elcapitan (2.04 MB, application/zip)
2017-05-16 01:54 PDT, Build Bot
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (28.72 MB, application/zip)
2017-05-16 02:30 PDT, Build Bot
no flags
Patch (123.90 KB, patch)
2017-05-17 20:01 PDT, Keith Miller
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (7.89 MB, application/zip)
2017-05-17 22:22 PDT, Build Bot
no flags
Patch (125.22 KB, patch)
2017-05-18 10:34 PDT, Keith Miller
no flags
Patch for landing (125.49 KB, patch)
2017-05-18 10:41 PDT, Keith Miller
no flags
Radar WebKit Bug Importer
Comment 1 2016-12-20 14:31:09 PST
JF Bastien
Comment 2 2017-04-11 10:52:02 PDT
We must make sure that postMessage of a WebAssembly.Memory does the right thing, same of its underlying .buffer.
Keith Miller
Comment 3 2017-05-15 23:06:03 PDT
Saam Barati
Comment 4 2017-05-15 23:20:05 PDT
Comment on attachment 310230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310230&action=review r=me with comment > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3001 > + if (!arrayBuffer->isTransferable()) { I wouldn’t do it quite like this, since this error message only makes sense given the above isShared check. Maybe remove the above check and come up with a more descriptive way of having different error messages for different untransferable arrays? Alternatively, you could have a more generic message. Perhaps you could even have a bit that says if it’s Wasm, and if so, have a more descriptive message
JF Bastien
Comment 5 2017-05-15 23:21:34 PDT
Comment on attachment 310230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310230&action=review Missing the FIXME in JSTests/wasm/js-api/test_basic_api.js I'm not familiar with all the places where the transferability should be checked, so it would be good to have another set of eyes look and make sure this is correct. > Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp:71 > + m_buffer->makeNonTransferable(); There's also code in WebAssemblyModuleConstructor.cpp which needs this. > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3003 > + throwVMTypeError(&state, scope, ASCIILiteral("Cannot transfer a WebAssembly.Memory")); Weird that the property is "non-transferable" but the error message knows it's a WebAssembly.Memory. I'd change one to match the other. > LayoutTests/ChangeLog:7 > + Can you explain that this dups Saam's dup of the de-modularized Builder?
JF Bastien
Comment 6 2017-05-15 23:31:11 PDT
> > Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp:71 > > + m_buffer->makeNonTransferable(); > > There's also code in WebAssemblyModuleConstructor.cpp which needs this. Oops ignore me, this one's fine because it's always a copy.
JF Bastien
Comment 7 2017-05-15 23:41:14 PDT
Comment on attachment 310230 [details] Patch r+ back (with nits) because I derp.
Keith Miller
Comment 8 2017-05-16 00:11:22 PDT
Comment on attachment 310230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310230&action=review >> Source/WebCore/bindings/js/SerializedScriptValue.cpp:3001 >> + if (!arrayBuffer->isTransferable()) { > > I wouldn’t do it quite like this, since this error message only makes sense given the above isShared check. Maybe remove the above check and come up with a more descriptive way of having different error messages for different untransferable arrays? Alternatively, you could have a more generic message. Perhaps you could even have a bit that says if it’s Wasm, and if so, have a more descriptive message How would you feel changing the code above to: if (!arrayBuffer->isTransferable()) { auto scope = DECLARE_THROW_SCOPE(vm); throwVMTypeError(&state, scope, transferErrorForArrayBuffer(arrayBuffer)) return Exception { ExistingExceptionError }; } where transferErrorForArrayBuffer(arrayBuffer) maps to "Cannot transfer a WebAssembly.Memory" / "Cannot transfer a SharedArrayBuffer" for wasm memory / SAB, respectively. >> LayoutTests/ChangeLog:7 >> + > > Can you explain that this dups Saam's dup of the de-modularized Builder? Done.
Keith Miller
Comment 9 2017-05-16 00:18:53 PDT
Keith Miller
Comment 10 2017-05-16 00:19:44 PDT
Created attachment 310238 [details] Patch for landing
Saam Barati
Comment 11 2017-05-16 00:30:53 PDT
(In reply to Keith Miller from comment #8) > Comment on attachment 310230 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=310230&action=review > > >> Source/WebCore/bindings/js/SerializedScriptValue.cpp:3001 > >> + if (!arrayBuffer->isTransferable()) { > > > > I wouldn’t do it quite like this, since this error message only makes sense given the above isShared check. Maybe remove the above check and come up with a more descriptive way of having different error messages for different untransferable arrays? Alternatively, you could have a more generic message. Perhaps you could even have a bit that says if it’s Wasm, and if so, have a more descriptive message > > How would you feel changing the code above to: > Sounds good. > if (!arrayBuffer->isTransferable()) { > auto scope = DECLARE_THROW_SCOPE(vm); > throwVMTypeError(&state, scope, transferErrorForArrayBuffer(arrayBuffer)) > return Exception { ExistingExceptionError }; > } > > where transferErrorForArrayBuffer(arrayBuffer) maps to "Cannot transfer a > WebAssembly.Memory" / "Cannot transfer a SharedArrayBuffer" for wasm memory > / SAB, respectively. > > >> LayoutTests/ChangeLog:7 > >> + > > > > Can you explain that this dups Saam's dup of the de-modularized Builder? > > Done.
Build Bot
Comment 12 2017-05-16 01:16:54 PDT
Comment on attachment 310238 [details] Patch for landing Attachment 310238 [details] did not pass jsc-ews (mac): Output: http://webkit-queues.webkit.org/results/3749045 New failing tests: jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-no-cjit wasm.yaml/wasm/js-api/memory-grow.js.wasm-no-call-ic jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-no-ftl stress/class-subclassing-string.js.ftl-eager jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-ftl-eager-no-cjit jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-ftl-no-cjit wasm.yaml/wasm/js-api/memory-grow.js.wasm-no-cjit jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-dfg-eager-no-cjit wasm.yaml/wasm/js-api/memory-grow.js.wasm-eager-jettison wasm.yaml/wasm/js-api/memory-grow.js.default-wasm jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout jsc-layout-tests.yaml/js/script-tests/parser-syntax-check.js.layout-no-llint
Build Bot
Comment 13 2017-05-16 01:42:25 PDT
Comment on attachment 310238 [details] Patch for landing Attachment 310238 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3749141 New failing tests: workers/wasm-mem-post-message.html workers/sab/postMessage-transfer-type-error.html
Build Bot
Comment 14 2017-05-16 01:42:27 PDT
Created attachment 310243 [details] Archive of layout-test-results from ews103 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 15 2017-05-16 01:48:53 PDT
Comment on attachment 310238 [details] Patch for landing Attachment 310238 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/3749152 New failing tests: workers/wasm-mem-post-message.html workers/sab/postMessage-transfer-type-error.html
Build Bot
Comment 16 2017-05-16 01:48:55 PDT
Created attachment 310245 [details] Archive of layout-test-results from ews106 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 17 2017-05-16 01:54:01 PDT
Comment on attachment 310238 [details] Patch for landing Attachment 310238 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3749144 New failing tests: workers/wasm-mem-post-message.html workers/sab/sent-from-worker-no-transfer.html workers/sab/postMessage-transfer-type-error.html
Build Bot
Comment 18 2017-05-16 01:54:02 PDT
Created attachment 310246 [details] Archive of layout-test-results from ews112 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 19 2017-05-16 02:30:43 PDT
Comment on attachment 310238 [details] Patch for landing Attachment 310238 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3749234 New failing tests: workers/wasm-mem-post-message.html workers/sab/postMessage-transfer-type-error.html
Build Bot
Comment 20 2017-05-16 02:30:45 PDT
Created attachment 310248 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Keith Miller
Comment 21 2017-05-17 20:01:17 PDT
Build Bot
Comment 22 2017-05-17 22:22:32 PDT
Comment on attachment 310476 [details] Patch Attachment 310476 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3766663 New failing tests: workers/wasm-mem-post-message.html
Build Bot
Comment 23 2017-05-17 22:22:34 PDT
Created attachment 310488 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Keith Miller
Comment 24 2017-05-18 10:34:11 PDT
Saam Barati
Comment 25 2017-05-18 10:38:56 PDT
Comment on attachment 310516 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310516&action=review r=me > Source/WebCore/ChangeLog:9 > + Make it not possible to transfer an ArrayBuffer that is backing a > + wasm memory. backing => backed by > Source/JavaScriptCore/runtime/ArrayBuffer.h:163 > + bool m_isWasmMemory : 1; Don't you need to always initialize this to false? I don't see where you do that.
Keith Miller
Comment 26 2017-05-18 10:41:41 PDT
Created attachment 310518 [details] Patch for landing
Keith Miller
Comment 27 2017-05-18 10:42:22 PDT
Comment on attachment 310516 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310516&action=review >> Source/WebCore/ChangeLog:9 >> + wasm memory. > > backing => backed by Changed. >> Source/JavaScriptCore/runtime/ArrayBuffer.h:163 >> + bool m_isWasmMemory : 1; > > Don't you need to always initialize this to false? I don't see where you do that. Good catch, Fixed.
WebKit Commit Bot
Comment 28 2017-05-18 11:22:22 PDT
Comment on attachment 310518 [details] Patch for landing Clearing flags on attachment: 310518 Committed r217052: <http://trac.webkit.org/changeset/217052>
WebKit Commit Bot
Comment 29 2017-05-18 11:22:24 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.