Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

StackOverflow error in scodec lazily #95

Open
Jacarte opened this issue Oct 30, 2020 · 4 comments
Open

StackOverflow error in scodec lazily #95

Jacarte opened this issue Oct 30, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Jacarte
Copy link
Contributor

Jacarte commented Oct 30, 2020

Hi @satabin

I was trying to decode/encode a large WASM module (here you can find it).

When I try to decode the binary swam launches a StackOverflow in this location

case OpCode.Block => block.decode(remainder).map(_.map(Block))
,
.encode(tpe ~ insts)
and here
blockType ~ lazily(expr)
. It seems to be an issue with the lazily option of scodec and the size of the recursion.

Any idea?

Thanks in advancne

@satabin
Copy link
Owner

satabin commented Nov 10, 2020

I can't figure out what I could do in this case. Does the wasm file has deeply nested blocks? I wanted to rewrite the binary parser to not use this library anymore, this could be a good opportunity.

@satabin satabin added the bug Something isn't working label Nov 10, 2020
@satabin satabin self-assigned this Nov 10, 2020
@Jacarte
Copy link
Contributor Author

Jacarte commented Nov 17, 2020

Hi Lucas,

If you plan to do so, maybe is a good idea to add the extra wasm sections in the engine. Take a look at https://github.com/v8/v8/blob/4b9b23521e6fd42373ebbcb20ebe03bf445494f9/src/wasm/wasm-constants.h#L74 . I was trying to play with the ffmpeg wasm file and it seems to have extra, non-custom sections,12 and 13. I tried to parse it with wabt and wasabi and they are not implementing this parsing. Have you read about these sections?

I will open a new issue on this

@satabin
Copy link
Owner

satabin commented Nov 17, 2020

I didn't read about these sections yet, I just followed what is specified so far. I will have a look.

@Jacarte
Copy link
Contributor Author

Jacarte commented Nov 18, 2020

It seems to be the bulk memory operation feature, https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md. Here is the roadmap defined in the official site https://webassembly.org/roadmap/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants