这个错误在C中意味着什么:free():next next(fast):0x00000000020b0200

时间:2014-02-10 20:38:01

标签: c scope free

我使用for循环来创建自定义数据结构的对象,并对它们执行一些操作。对象包含ucontext_t个字段,因此我基本上在执行makecontextswapcontext。每个ucontext_t对象的堆栈大小分配是默认的SIGSTKSZ

使用gcc编译程序后,运行结果中包含以下错误。这个错误是否意味着在退出程序之前我的内存没有被释放?一般来说,你能从这个错误中得知什么?

*** glibc detected *** ./a.out: free(): invalid next size (fast): 0x00000000020b0200 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7ffeb31acb96]
./a.out[0x401261]
./a.out[0x4009fe]
/lib/x86_64-linux-gnu/libc.so.6(+0x364a0)[0x7ffeb31644a0]
./a.out[0x401080]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7ffeb314f76d]
./a.out[0x400899]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:01 23921                              /home/cs/Development/C/gtthreads_fresh/a.out
00601000-00602000 r--p 00001000 08:01 23921                              /home/cs/Development/C/gtthreads_fresh/a.out
00602000-00603000 rw-p 00002000 08:01 23921                              /home/cs/Development/C/gtthreads_fresh/a.out
020a2000-020c5000 rw-p 00000000 00:00 0                                  [heap]
7ffeb2f18000-7ffeb2f2d000 r-xp 00000000 08:01 136328                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffeb2f2d000-7ffeb312c000 ---p 00015000 08:01 136328                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffeb312c000-7ffeb312d000 r--p 00014000 08:01 136328                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffeb312d000-7ffeb312e000 rw-p 00015000 08:01 136328                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffeb312e000-7ffeb32e3000 r-xp 00000000 08:01 136874                     /lib/x86_64-linux-gnu/libc-2.15.so
7ffeb32e3000-7ffeb34e3000 ---p 001b5000 08:01 136874                     /lib/x86_64-linux-gnu/libc-2.15.so
7ffeb34e3000-7ffeb34e7000 r--p 001b5000 08:01 136874                     /lib/x86_64-linux-gnu/libc-2.15.so
7ffeb34e7000-7ffeb34e9000 rw-p 001b9000 08:01 136874                     /lib/x86_64-linux-gnu/libc-2.15.so
7ffeb34e9000-7ffeb34ee000 rw-p 00000000 00:00 0 
7ffeb34ee000-7ffeb3510000 r-xp 00000000 08:01 137879                     /lib/x86_64-linux-gnu/ld-2.15.so
7ffeb36f9000-7ffeb36fc000 rw-p 00000000 00:00 0 
7ffeb370c000-7ffeb3710000 rw-p 00000000 00:00 0 
7ffeb3710000-7ffeb3711000 r--p 00022000 08:01 137879                     /lib/x86_64-linux-gnu/ld-2.15.so
7ffeb3711000-7ffeb3713000 rw-p 00023000 08:01 137879                     /lib/x86_64-linux-gnu/ld-2.15.so
7fff659db000-7fff659fc000 rw-p 00000000 00:00 0                          [stack]
7fff659fe000-7fff65a00000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)

1 个答案:

答案 0 :(得分:1)

这意味着要么释放无效地址,要么更有可能覆盖已分配块的边界。 @Cantfindmyname给了你I get this error: "glibc detected",它告诉你问题是什么,而不是如何找出你的程序导致问题的地方,因为这些事情很难找到。这里最好的工具是valgrind,它会(通常)很快发现你正在做的任何顽皮的内存,尤其是堆内存。