Skip to content

Crash in wasm-opt due to infinite recursion in GenerateStackIR::doWalkFunction #1903

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

Closed
msorvig opened this issue Feb 7, 2019 · 6 comments
Closed

Comments

@msorvig
Copy link

msorvig commented Feb 7, 2019

When running wasm-opt ./gui_opengl.wasm.pre -o ./gui_opengl.wasm -Os
Using binaryen version_55

Stack trace:

frame #0: 0x000000010000fbb8 wasm-optMixedArena::allocSpace(unsigned long, unsigned long) + 8
frame #1: 0x000000010014d74a wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 42 frame #2: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387
frame #3: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387 frame #4: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387`

...

frame #5447: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387
frame #5448: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387 frame #5449: 0x000000010014d491 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitPossibleBlockContents(wasm::Expression*) + 177
frame #5450: 0x000000010014dc20 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitLoop(wasm::Loop*) + 272 frame #5451: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387
frame #5452: 0x000000010014d8a3 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitBlock(wasm::Block*) + 387 frame #5453: 0x000000010014d491 wasm-optwasm::StackWriter<(wasm::StackWriterMode)1, wasm::GenerateStackIR::doWalkFunction(wasm::Function*)::Parent>::visitPossibleBlockContents(wasm::Expression*) + 177
frame #5454: 0x000000010014d27b wasm-optwasm::GenerateStackIR::doWalkFunction(wasm::Function*) + 171 frame #5455: 0x000000010014b62d wasm-optwasm::WalkerPass<wasm::PostWalker<wasm::GenerateStackIR, wasm::Visitor<wasm::GenerateStackIR, void> > >::runOnFunction(wasm::PassRunner*, wasm::Module*, wasm::Function*) + 29
frame #5456: 0x000000010009bd0b wasm-optwasm::PassRunner::runPassOnFunction(wasm::Pass*, wasm::Function*) + 219 frame #5457: 0x000000010009c6de wasm-optstd::__1::__function::__func<wasm::PassRunner::run()::$_1::operator()() const::'lambda'(), std::__1::allocator<wasm::PassRunner::run()::$_1::operator()() const::'lambda'()>, wasm::ThreadWorkState ()>::operator()() + 110
frame #5458: 0x00000001002054c6 wasm-optwasm::Thread::mainLoop(void*) + 86 frame #5459: 0x00000001002062dc wasm-optvoid* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, void ()(void), wasm::Thread*> >(void*) + 44
frame #5460: 0x00007fff6659b305 libsystem_pthread.dylib_pthread_body + 126 frame #5461: 0x00007fff6659e26f libsystem_pthread.dylib_pthread_start + 70
frame #5462: 0x00007fff6659a415 libsystem_pthread.dylibthread_start + 13^C

@msorvig
Copy link
Author

msorvig commented Feb 7, 2019

Attaching wasm file which reproduces the crash: gui_opengl.wasm.zip

@kripken
Copy link
Member

kripken commented Feb 7, 2019

I don't see a crash on linux, but that might be because linux stacks are 8MB, and I think you're on MacOS, which has smaller ones?

So my guess is this is not an infinite recursion, just a very deep one. If so, #1905 should fix it.

@msorvig
Copy link
Author

msorvig commented Feb 8, 2019

Yep, this was on macOS.

I tried running with "ulimit -s 65532" (64MB, the maximum allowed value) now but I still get the crash.

@kripken
Copy link
Member

kripken commented Feb 8, 2019

Odd that didn't fix it. Can you please try with that PR, does that fix it?

@msorvig
Copy link
Author

msorvig commented Feb 12, 2019

Yes, applying #1905 fixes the issue. Thanks!

(looks like removing the debug output there was sufficient, for my test case)

@kripken
Copy link
Member

kripken commented Feb 12, 2019

Thanks for checking!

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

2 participants