-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
emcc and em++ generate different result for the same source code. #689
Comments
I can reproduce the problem. I poked around with some debugging tools, but it's hard to say what is going wrong here. Comparing memory logs fails because the C++ build uses slightly more memory - it has some strings that are different, things like that. So it is possible that some C++ vs C difference in those strings is the cause, and it hits an underlying bug in the code. Or, it could be that some code conversion limitation is hit. The closest I can think of is we have seen issues with compiling C++ and C code and calling a function from one to the other. So if some code is compiled using em++, all probably should be. Although we should throw an error on that, and I don't see one. LABEL_DEBUG does show the hang is inside |
Thanks, Alon. I tried dig into the source code a little bit. And the problem occurs in the standard library, with the following code:
For those who are not familiar with Ruby, what this piece of code does is to invoke "include" method of "Array" class object with the argument "Enumerable". And for some reason, the self variable which should point to "Array" class object is invalid. It maybe the case that the ruby virtual machine failed to map the literal string "Array" to the correct class object, or it maybe the case that the value is right, but some how got truncated in the calling chain from decoding the opcode of the ruby vm, to the actual calling of _mrb_include_module. Anyway, I will continue to investigate in this and update this issue when I got more findings. Thanks again for you help! |
After some time of debugging, I found one bug which may (or may not) be the reason of this issue. I created another issue with a simplified version of source to debug. |
I've just tested the code with the new commit for issue #705. It did fix this problem, I've also updated the mruby-browser project pointing to the new commit: xxuejie/mruby-browser@9044daf. Thanks @kripken for the very fast fix! |
Hi there,
I ported mruby to the browser via emscripten, the source code is at https://github.com/xxuejie/mruby-browser. However, I found that if I build the source using emcc, the result js file will run forever. But if I change to build with em++, the code is working without any problem.
How to build with em++:
git clone git://github.com/xxuejie/mruby-browser.git
git checkout master
make clean
./script/bootstrap
How to build with emcc:
(for the same source code)
git checkout build-with-emcc
make clean
./script/bootstrap
The diff file of the two generated js file is at https://github.com/xxuejie/mruby-browser/blob/build-with-emcc/diff.tar.gz. But it is very huge(~3MB unzipped).
The text was updated successfully, but these errors were encountered: