开发者

Valgrind error: invalid write of size 4 (but says error is in free() )

开发者 https://www.devze.com 2023-04-13 06:56 出处:网络
First, here is the message valgrind gives me (this is just one error, I get the same message several times)

First, here is the message valgrind gives me (this is just one error, I get the same message several times)

==25248== Invalid write of size 4
==25248==    at 0x4024B3A: free (vg_replace_malloc.c:366)
==25248==    by 0x8048F5E: sthread_free_ctx (sthread_ctx.c:86)
==25248==    by 0x8048开发者_JS百科9C1: sthread_user_exit (sthread_user.c:105)
==25248==    by 0x804883C: dispatcher (sthread_user.c:40)
==25248==  Address 0x41a6148 is 65,376 bytes inside a block of size 65,536 free'd
==25248==    at 0x4024B3A: free (vg_replace_malloc.c:366)
==25248==    by 0x8048F5E: sthread_free_ctx (sthread_ctx.c:86)
==25248==    by 0x80489C1: sthread_user_exit (sthread_user.c:105)
==25248==    by 0x804883C: dispatcher (sthread_user.c:40)

I dont understand it, because I am used to getting this error when I dont malloc enough space, so why am I getting the error when I am trying to free something?? what is being written?

thanks


It is difficult to tell with so little information (particularly: no code), but it looks to me like you may be attempting to call free on a pointer which refers to an offset into a memory region which has already been freed by an earlier call to free. free needs to manipulate the heap data structures, so it is not surprising that it is attempting to write to the memory region.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号