Skip to content

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

Closed

Description

@malbarbo

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

The error can be reproduced running asm2wasm on this file.

Activity

  1. kripken commented on Jun 9, 2017

    @kripken
    Member

    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.

  2. malbarbo commented on Jun 9, 2017

    @malbarbo
    Author

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

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

  3. malbarbo commented on Jun 9, 2017

    @malbarbo
    Author

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

  4. kripken commented on Jun 12, 2017

    @kripken
    Member

    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?

  5. malbarbo commented on Jun 12, 2017

    @malbarbo
    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.

  6. kripken commented on Jun 13, 2017

    @kripken
    Member

    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.)

  7. malbarbo commented on Jun 13, 2017

    @malbarbo
    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.

  8. malbarbo commented on Jun 13, 2017

    @malbarbo
    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?

  9. added a commit that references this issue on Jun 13, 2017
    d7a2146
  10. kripken commented on Jun 13, 2017

    @kripken
    Member

    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.)

  11. rfk commented on Jun 14, 2017

    @rfk
    Contributor

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

  12. added a commit that references this issue on Jun 17, 2017
    7a5744d
  13. kripken commented on Jun 17, 2017

    @kripken
    Member

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

  14. malbarbo commented on Jun 19, 2017

    @malbarbo
    Author

    Thanks @kripken!

  15. lilianmoraru commented on Jun 20, 2017

    @lilianmoraru

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

  16. kripken commented on Jun 20, 2017

    @kripken
    Member

    I tagged 1.37.14 now.

  17. lilianmoraru commented on Jun 20, 2017

    @lilianmoraru

    @kripken Thank you!!

  18. added a commit that references this issue on Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions