Stack overflow in unmanaged: IP: 0x26eb76, fault addr: 0xbf808ffc

匆匆过客 提交于 2019-12-05 18:48:57

问题


My Mono application crashes on Mac with this message (Full log):

$ mono --debug bin/Debug/SparkleShare.app/Contents/MonoBundle/SparkleShare.exe
[...]
Stack overflow in unmanaged: IP: 0x26eb76, fault addr: 0xbf808ffc
[...]

"in unmanaged" implies that the stack overflow is not in my code (I only have managed code) but rather in a library I embed (SQLite, DotCmis, NewtonSoft.Json) or in Mono's code.

Even though I compile and run in Debug mode, all I get is these two hexadecimals.

QUESTION: How can I investigate this stack overflow? Any trick?

Note: The same libraries (with pretty much the same code) run fine on Linux and Windows.


回答1:


Handling stack overflow is quite tricky (for mono), so it might very well be that the stack overflow is actually yours. The problem lies in figuring out the stack trace.

I usually run with gdb:

gdb --args mono --debug bin/Debug/SparkleShare.app/Contents/MonoBundle/SparkleShare.exe

And then try to hit Ctrl+C after the stack has begun to grow, but before it has actually overflown (gdb gets seriously confused with stack overflows, and you'll usually have to exit gdb when that happens, which is why you'll need to catch the overflow in action).

After hitting Ctrl+C, do a thread apply all backtrace, and you'll know if a stack overflow is about to happen (one thread will have thousands of frames).

Once you have an enormous stack trace in gdb, you need to identify the cycle. This is usually quite easy just by looking at the addresses of the stack trace. Once you have this data, you can get the managed frame like this:

(gdb) p mono_pmip (0xdeaddead)
$1 = 0x0000dead  "Managed frame information shows up here"

Then just do the same for all the frames in the cycle you found.

There are more tips for debugging mono with gdb here.



来源:https://stackoverflow.com/questions/13682308/stack-overflow-in-unmanaged-ip-0x26eb76-fault-addr-0xbf808ffc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!