Giter Club home page Giter Club logo

Comments (4)

yagehu avatar yagehu commented on July 19, 2024 1

Not maintainer. Just to answer your question. Wasm is a stack machine with an implicit stack. So an instruction like i32.const 10 pushes a 32-bit integer with a value of 10 onto the stack. An instruction like i32.add pops 2 values off the stack, adds them, and pushes the result back onto the stack. This error can occur if the generated wasm did not "typecheck" (validate) successfully and there are values remaining on the stack. So a good block without any values remaining may look like:

i32.const 1 ; 1 value on the stack
i32.const 2 ; 2 values on the stack
i32.add     ; 1 value on the stack
drop        ; no values on the stack. All good!

from wasmer.

yizhuoliang avatar yizhuoliang commented on July 19, 2024

Oh thank you for this information, yeah, I think I have a sense of what's wrong here. I think if I go over the components carefully, I can figure the error out. But I'm also wondering if there are some easier way to ping-poing the issue. When I use wasm2wat on the newhello.wasm, I got more detailed error description of the mismach

root@2299d4e20d1f:/lind-glibc/replace-sysroot/test# wasm2wat newhello.wasm -o newhello.wat
newhello.wasm:00001c6: error: type mismatch at end of function, expected [] but got [i32, i32]

Then is there a way to know what is this function that causes this?
Since I'm building my own libc, and manually locating the error is probably too hard due to the complexity of the codebase.

from wasmer.

yizhuoliang avatar yizhuoliang commented on July 19, 2024

Okay I see a good way, while wasm2wat checks the stack issue and give the offset of where the error occurs, we can use wasm-objdump -d to look at the offset position in the file, and know which function is causing the type mismatch

from wasmer.

theduke avatar theduke commented on July 19, 2024

@yagehu thanks for jumping in...

from wasmer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.