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

asm2wasm: Assertion `functionsMap.find(curr->name) == functionsMap.end()' failed #5288

Closed
malbarbo opened this issue Jun 9, 2017 · 15 comments

Comments

@malbarbo
Copy link

malbarbo commented Jun 9, 2017

I got this assertion error trying to build libc-test (an rust crate).

The error can be reproduced running asm2wasm on this file.

@kripken
Copy link
Member

kripken commented Jun 9, 2017

Looks like that asm.js has a duplicate function,

function _memset($0,$1,$2) {
function _memset(ptr, value, num) {

Do you have the bitcode that it was generated from? The bug is probably at the bitcode => asm.js level.

@malbarbo
Copy link
Author

malbarbo commented Jun 9, 2017

Here is it: libc_test-fe212f5bb0be8707.0.o.zip

I'm using rust 1.18, which uses llvm 4.0...

@malbarbo
Copy link
Author

malbarbo commented Jun 9, 2017

The same error happens with rust 1.17, which uses llvm 3.9.

@kripken
Copy link
Member

kripken commented Jun 12, 2017

I'm not able to test this on emscripten incoming (1.37.13), as I get

$ emcc libc_test-fe212f5bb0be8707.0.o
llc: fastcomp/include/llvm/ADT/ilist_iterator.h:126: llvm::ilist_iterator<OptionsT, IsReverse, IsConst>::reference llvm::ilist_iterator<OptionsT, IsReverse, IsConst>::operator*() const [with OptionsT = llvm::ilist_detail::node_options<llvm::BasicBlock, true, false, void>; bool IsReverse = false; bool IsConst = false; llvm::ilist_iterator<OptionsT, IsReverse, IsConst>::reference = llvm::BasicBlock&]: Assertion `!NodePtr->isKnownSentinel()' failed.

Does that emcc command work for you? Or is there another way I should be reproducing the problem?

@malbarbo
Copy link
Author

Thanks for investigate this.

I can execute emcc libc_test-fe212f5bb0be8707.0.o with sdk-1.37.13-64bit, but there is missing symbol errors.

I think that the best way is to execute the rust compiler... If you do not want to install the rust compiler in your system, you can run it inside a docker container (if you install rustup outside a container, you can uninstall it with the command rustup uninstall, which removes everything that was installed):

git clone https://github.com/malbarbo/libc --branch emscripten
docker run -it -v $(pwd)/libc:/libc ubuntu:16.04
apt-get update && apt-get install curl build-essential
curl https://sh.rustup.rs -sSf | sh # choose option 1
. ~/.profile # set PATH
rustup target add wasm32-unknown-emscripten
# install emscripten
cd /libc
RUSTFLAGS="-Z print-link-args" cargo run --target wasm32-unknown-emscripten -p libc-test

The artifacts are generate in target/wasm32-unknown-emscripten/debug/deps. Setting RUSTFLAGS will print the arguments used to call emcc.

@kripken
Copy link
Member

kripken commented Jun 13, 2017

If it doesn't crash for you with that version, then I suspect it's because the sdk build doesn't have assertions, while my local build does. I think we need to find out what's causing those asserts, as they could be the reason for the bug reported here (but it's also possible it's a red herring).

Perhaps is the bitcode old, or being linked with something old? A full rebuild from scratch of all bitcode files might help.

(I could try the rust compiler, but I don't know enough about it to easily debug into it. What I need here is just the emscripten commands it issues.)

@malbarbo
Copy link
Author

Using emscripten incoming I got the same error as you.

I create a a zip file with all required obj files to generate an .js. The command emcc *.o *.rlib works fine, but the command emcc -s WASM=1 *.o *.rlib fail with the original assertion error.

@malbarbo
Copy link
Author

To make it clear, using emcc libc_test-fe212f5bb0be8707.0.o gives the same assertion error you got, but given all object files as parameters works. Is this another issue?

kripken added a commit that referenced this issue Jun 13, 2017
…ented in compiled code, do not add from the library - it may be duplicate code if we do. instead, make sure to export the compiled version so js libraries can reach it. fixes #5288
@kripken
Copy link
Member

kripken commented Jun 13, 2017

Thanks, now I can see the problem directly. #5299 should fix it.

(I don't see those assertions again, btw - that might be an entirely separate issue. Very strange.)

@rfk
Copy link
Contributor

rfk commented Jun 14, 2017

FWIW I also hit this issue today in a different codebase, and can confirm that #5299 fixed it for me.

kripken added a commit that referenced this issue Jun 17, 2017
…ented in compiled code, do not add from the library - it may be duplicate code if we do. instead, make sure to export the compiled version so js libraries can reach it. fixes #5288 (#5299)
@kripken
Copy link
Member

kripken commented Jun 17, 2017

Thanks for confirming @rfk. Should be fixed now with that PR merged.

@kripken kripken closed this as completed Jun 17, 2017
@malbarbo
Copy link
Author

Thanks @kripken!

@lilianmoraru
Copy link

It would be nice to have this fix.
@kripken When do you think the next patch release might happen?

@kripken
Copy link
Member

kripken commented Jun 20, 2017

I tagged 1.37.14 now.

@lilianmoraru
Copy link

@kripken Thank you!!

malbarbo added a commit to malbarbo/libc that referenced this issue Jun 20, 2017
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

4 participants