New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 781123 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 16
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

asm.js validation error

Reported by caiiiy...@gmail.com, Nov 3 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0

Steps to reproduce the problem:
1. Download attached archive
2. Open html page in chrome -> you will see asm.js validation error
3. Open html page in FF -> you will see that asm.js compiled successfully
4. Run sed -i "s/\([A-Za-z$]\)<<2>>2/(\\1<<2)>>2/ig" Build/bin.asm.code.unityweb - This step will add unnecessary parens and fix the problem
5. Open page in chrome, now all ok

What is the expected behavior?
Original code should pass validation without unnecessary paren

What went wrong?
Orignal code does not pass validation step in Chrome

Did this work before? N/A 

Chrome version: 61.0.3163.100 57c9d07b416b5a2ea23d28247300e4af36329bdc-refs/branch-heads/3163@{#1250}  Channel: stable
OS Version: Ubuntu 16.04
Flash Version: Shockwave Flash 27.0 r0

This code is produced by unity exporter (emscripten). After that this code was optimized by Similar-Function-Elimination algorithm. It uses esprima, after this optimization steps unnecessary parens are removed. But it breaks validation in Chrome.

To find where problem I use sed:

sed -i "s/0;/0;\n/ig" bin.asm.code.unityweb

After doing this I have this error:

bin.asm.code.unityweb:419968 Invalid asm.js: Unexpected token

Problem line:
c[$<<2>>2]=a;return}function $$F(a,$){a=a|0;

After digging I found that problem is in:
$<<2>>2

If I replace it with ($<<2)>>2 then it pass validation on this line. 
After that I replace all similar places with sed:

sed -i "s/\([A-Za-z$]\)<<2>>2/(\\1<<2)>>2/ig" bin.asm.code.unityweb

and this solve the problem.
 
uplatformer.zip
7.3 MB Download
Labels: Needs-Triage-M61

Comment 2 by e...@chromium.org, Nov 7 2017

Components: -Blink Blink>JavaScript>WebAssembly
Cc: bradnelson@chromium.org
Owner: mstarzinger@chromium.org
Status: Assigned (was: Unconfirmed)
mstarzinger, could you please take a look?
Status: Fixed (was: Assigned)
I downloaded and tried the example and got:

% ~/current-v8/out.gn/Release/d8 --trace-asm-parser bin.asm.code.unityweb 
[asm.js translation successful: time=921.368ms, translate_zone=82382KB, compile_zone+=35330KB]
bin.asm.code.unityweb:1: ReferenceError: Module is not defined
Module["asm"] = (function(global,env,buffer) {
^
ReferenceError: Module is not defined
    at bin.asm.code.unityweb:1:1

So the asm validator worked.

Sign in to add a comment