*** glibc detected *** sendip: free(): invalid next size (normal): 0x09da25e8 *** [duplicate]

你。 提交于 2019-12-06 15:26:55

Probably you've messed badly with memory, writing things where you shouldn't (e.g., due to buffer overflows).

If you are wondering how a buffer overflow can cause an "invalid free" error, then consider the following example.

Suppose you've allocated dynamically an array A of 10 bytes, and then a structure B.

C runtimes usually places informations about allocated chunks of memory released by malloc/new just before the address returned to the user, so it is easy to get back the size at free invocation.

Now, suppose that you mess with array subscripts and do A[11] = value. Your value will be placed in the field reserved by the C runtime to store the aforementioned informations, turning them meaninglessness, so the C runtime will catch the error trying to free B and abort the execution.

Since you are on Linux, you can use Valgrind to track down the problem and eliminating it.

The error message means that glibc has detected memory corruption, which is bad. The sendip program may have a bug. For instance, it may be free()ing memory at the wrong time, or multiple times, or there may be a stray pointer.

I suggest that you report this bug to the authors of sendip. Send them all of this information.

I also suggest that you check what is the latest version of sendip, available from its developers, and try compiling from their latest copy of the source code. It is possible that the latest version fixes this bug.

If you want to try to troubleshoot further, I suggest running your sendip command line under valgrind, and then cut-and-paste the results here and report them to the developers of sendip. It would also help if you installed debugging symbols for sendip, or recompiled it from source with debugging symbols enabled.

The valgrind output is pointing you right at the bug:

==12444== Invalid write of size 1

The program wrote to memory that it shouldn't have.

==12444==    at 0x4027F40: memcpy (mc_replace_strmem.c:635)
==12444==    by 0x4032269: do_opt (esp.c:113)
==12444==    by 0x804A51D: main (sendip.c:575)

This is a stack trace at the point of the offending write. memcpy just does what it's told, so the fault is in do_opt, at line 113 of esp.c. Depending on optimization, you may or may not find a call to memcpy there, but something in that area is trying to copy a block of memory into the wrong place. The root cause of the bug is likely to be a bit above that, in the calculation of the destination address for the copy.

==12444==  Address 0x41cec5c is 5 bytes after a block of size 23 alloc'd

This describes where the program tried to write that it shouldn't have. "5 bytes after a [malloced block]" is exactly the sort of bad write that would cause the original error message from glibc's malloc, which puts (some of) its internal data structures in between blocks of memory allocated for the application's use.

Incidentally, the number 12444 is just the process ID of the program - it's useful if you're running something that calls fork under valgrind, but otherwise can be ignored.

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