Bug 163899 - WebAssembly API: test with neutered inputs
Summary: WebAssembly API: test with neutered inputs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: JF Bastien
URL:
Keywords: InRadar
Depends on:
Blocks: 161709
  Show dependency treegraph
 
Reported: 2016-10-24 10:29 PDT by JF Bastien
Modified: 2017-05-18 11:22 PDT (History)
14 users (show)

See Also:


Attachments
Patch (120.01 KB, patch)
2017-05-15 23:06 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (121.79 KB, patch)
2017-05-16 00:18 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (121.79 KB, patch)
2017-05-16 00:19 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
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 Details
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 Details
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 Details
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 Details
Patch (123.90 KB, patch)
2017-05-17 20:01 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
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 Details
Patch (125.22 KB, patch)
2017-05-18 10:34 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (125.49 KB, patch)
2017-05-18 10:41 PDT, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description JF Bastien 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).
Comment 1 Radar WebKit Bug Importer 2016-12-20 14:31:09 PST
<rdar://problem/29760348>
Comment 2 JF Bastien 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.
Comment 3 Keith Miller 2017-05-15 23:06:03 PDT
Created attachment 310230 [details]
Patch
Comment 4 Saam Barati 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
Comment 5 JF Bastien 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?
Comment 6 JF Bastien 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.
Comment 7 JF Bastien 2017-05-15 23:41:14 PDT
Comment on attachment 310230 [details]
Patch

r+ back (with nits) because I derp.
Comment 8 Keith Miller 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.
Comment 9 Keith Miller 2017-05-16 00:18:53 PDT
Created attachment 310237 [details]
Patch
Comment 10 Keith Miller 2017-05-16 00:19:44 PDT
Created attachment 310238 [details]
Patch for landing
Comment 11 Saam Barati 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.
Comment 12 Build Bot 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
Comment 13 Build Bot 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
Comment 14 Build Bot 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
Comment 15 Build Bot 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
Comment 16 Build Bot 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
Comment 17 Build Bot 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
Comment 18 Build Bot 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
Comment 19 Build Bot 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
Comment 20 Build Bot 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
Comment 21 Keith Miller 2017-05-17 20:01:17 PDT
Created attachment 310476 [details]
Patch
Comment 22 Build Bot 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
Comment 23 Build Bot 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
Comment 24 Keith Miller 2017-05-18 10:34:11 PDT
Created attachment 310516 [details]
Patch
Comment 25 Saam Barati 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.
Comment 26 Keith Miller 2017-05-18 10:41:41 PDT
Created attachment 310518 [details]
Patch for landing
Comment 27 Keith Miller 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.
Comment 28 WebKit Commit Bot 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>
Comment 29 WebKit Commit Bot 2017-05-18 11:22:24 PDT
All reviewed patches have been landed.  Closing bug.