Skip to content
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

"SyntaxError: invalid increment operand" on Firefox #2314

Closed
SBRK opened this issue Apr 24, 2014 · 22 comments
Closed

"SyntaxError: invalid increment operand" on Firefox #2314

SBRK opened this issue Apr 24, 2014 · 22 comments

Comments

@SBRK
Copy link

SBRK commented Apr 24, 2014

With emsdk version 1.13 and 1.16, on Firefox 28.0 on Windows, we are getting the following error :
SyntaxError: invalid increment operand

It used to work with an older version of Emscripten.

@SBRK
Copy link
Author

SBRK commented Apr 24, 2014

Not sure if it will be of any help but here is the line on which we get the error :
http://pastebin.com/6xF2rwqa

@juj
Copy link
Collaborator

juj commented Apr 24, 2014

This gets printed to web console at app startup time? Can you extract the issue into a small test case?

@juj
Copy link
Collaborator

juj commented Apr 24, 2014

Try building with -g2 to get a more readable version of the output that is not minified.

@SBRK
Copy link
Author

SBRK commented Apr 25, 2014

Yes it does get printed on the console at startup. I'll try to use g2 to get a more precise location of the problem

@SBRK
Copy link
Author

SBRK commented Apr 25, 2014

Ok there you go :
invoke_viidi(2, i24 | 0, i25 | 0, ++0, 0);

I'll also try to find the corresponding function in our c++ code

@SBRK
Copy link
Author

SBRK commented Apr 25, 2014

I've got the corresponding function, but the js function does 2000 lines, so it's not exactly ideal to pinpoint the problem :/

@JMLX42
Copy link

JMLX42 commented Apr 25, 2014

@SBRK
Copy link
Author

SBRK commented Apr 25, 2014

Another piece of information : there's only one ++0 in all of the generated js file, and replacing it by 1 makes it work on Firefox

@kripken
Copy link
Member

kripken commented Apr 25, 2014

Can you either give me a simple command to build that file by itself, or a link to the bitcode file? Either would allow me to reproduce the problem locally.

@JMLX42
Copy link

JMLX42 commented Apr 26, 2014

Hello,

here is a link to the bitcode file that should hold the function:

https://dl.dropboxusercontent.com/u/39247193/libminko-framework.a

It's the library for the Minko core framework. You can build it yourself using the following documentation:

http://doc.v3.minko.io/wiki/Compiling_the_SDK_for_HTML5

Regards,

@kripken
Copy link
Member

kripken commented Apr 29, 2014

Compiling that bitcode file with -O2 does not produce the bug. Do I need specific flags to build with?

@JMLX42
Copy link

JMLX42 commented Apr 30, 2014

thanks for your help!

flags for em++:

-O2 -MMD -MP

flags for emcc:

-O2 --closure 1 -s CLOSURE_ANNOTATIONS=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s DISABLE_EXCEPTION_CACHING=0 -s TOTAL_MEMORY=268435456

@kripken
Copy link
Member

kripken commented Apr 30, 2014

I still can't reproduce,

$emcc libminko-framework.a -O2 --closure 1 -s CLOSURE_ANNOTATIONS=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s DISABLE_EXCEPTION_CACHING=0 -s TOTAL_MEMORY=268435456
$node a.out.js
$

Does that fail on your machine?

@warrenseine
Copy link
Contributor

It does work, but this is not a good test :

  • the .js output doesn't contain the ++0 (but it definitely does when linked as a final binary)
  • node uses v8, and the issue only happens with Firefox

We'll try to isolate the problem.

@JMLX42
Copy link

JMLX42 commented May 22, 2014

Hello,

the error now happens in Chrome 35 too (did not happen with Chrome 34) with a different message:

"Uncaught ReferenceError: Invalid left-hand side expression in prefix operation"

You can see it live here: http://showcase.minko.io/assimp/index.html

This is now a major problem since our apps won't work in any up-to-date browser.
Any idea how to fix this?

Regards,

@juj
Copy link
Collaborator

juj commented May 22, 2014

In previous comment you mentioned that the repro kripken tried did not work. Do you have a full commandline that could be tried that is a good repro?

@JMLX42
Copy link

JMLX42 commented May 22, 2014

kripken's test only generates the bytecode but it seams the invalid "++0" is added during the compilation of the final JS code.

Here is our command line:

emcc minko-example-cube.bc -o bin/html5/release/minko-example-cube.js -O2 --closure 1 -s CLOSURE_ANNOTATIONS=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s DISABLE_EXCEPTION_CATCHING=0 -s OUTLINING_LIMIT=20000 --memory-init-file 1 --shell-file template.html --preload-file asset

The main problem is that the code base is pretty large and disabling some libraries will make the "++0" disapear without any reason (the problematic code originates from libminko-framework.a which is always the same...).

Here is how we compile everything in HTML5 using Emscripten + Premake:

http://doc.v3.minko.io/wiki/Compiling_the_SDK_for_HTML5

Thanks for your help!

@JMLX42
Copy link

JMLX42 commented May 22, 2014

For people with the same problem, we currently use a workaround with a Python script called on the generated JS file:

import tempfile, shutil, os, sys

file = sys.argv[1]
temp_file = tempfile.mktemp()
shutil.copyfile(file, temp_file)

with open(file, "wt") as fout:
    with open(temp_file, "rt") as fin:
        for line in fin:
            fout.write(line.replace('++0', '1'))

We use Premake's post-build commands to call "python fix.py invalid-file.js".

Regards,

@kripken
Copy link
Member

kripken commented May 22, 2014

Can you provide that .bc file in the emcc command 2 comments back? Then I can try it locally.

@JMLX42
Copy link

JMLX42 commented May 25, 2014

Sure! Here you go:

https://dl.dropboxusercontent.com/u/39247193/minko-example-cube.bc

Thanks again for your help!

kripken added a commit that referenced this issue May 27, 2014
@kripken
Copy link
Member

kripken commented May 27, 2014

Thanks! Ok, I reduced this to a testcase which shows it is an odd bug resulting from a combination of undefined float in an invoke context, so we end up casting twice, +(+0), which turns into ++0 and breaks us. Fixed on incoming.

@kripken kripken closed this as completed May 27, 2014
@JMLX42
Copy link

JMLX42 commented May 29, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants