sYSMALLOc: Assertion failed - any ideas how to debug effectively?

后端 未结 2 1636
臣服心动
臣服心动 2021-01-18 00:52

My server daemon works fine on most machines however on one I am getting:

malloc.c:3074: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)-         


        
相关标签:
2条回答
  • 2021-01-18 01:00

    This is almost certainly due to a heap corruption bug in your code (writing just before or just after an allocated block).

    Since you are apparently on Linux, the tool to use here is Valgrind. It should point you straight at the problem, and it should do so even on machines where your daemon "works".

    Trying anything other than Valgrind for this kind of problem is likely a waste of time.

    0 讨论(0)
  • 2021-01-18 01:12

    The assertion almost certainly indicates some kind of memory corruption prior to a call to malloc. Given that the assertion is tripping in xmpp_ctx_new, which appears to be a very early call in the libstrophe XMPP library, I'd say it's very likely that the bug is in your code (though it may not be if you're allocating several XMPP contexts - not sure if there's any reason to do that).

    If you're only allocating one XMPP context, you can isolate the bug to your code by inserting a call to malloc(sizeof(xmpp_ctx_t)) prior to calling xmpp_ctx_new, and you'll see the problem isn't in libstrophe. (Incidentally, I'm pretty sure the problem won't be in this call to xmpp_ctx_new because I google'd the source to the function (mem=0x0 looked likely to cause problems), and saw that it basically reduced to malloc and a few initializers - reading the source is generally a good strategy for looking for bugs in OSS.)

    0 讨论(0)
提交回复
热议问题