Catching a double free or corruption error with memcheck (a Valgrind tool)

I was randomly getting errors (1 run in 50 would reproduce) like:

$ ./myprogram
*** glibc detected *** double free or corruption (out): 0x093014a4 ***

Linux has a randomization of virtual address space which is supposed to help thwart buffer overflow attacks etc.

This can cause errors to randomly not show, so in the spirit of trying to consistently reproduce the problem I disabled this using:

$ setarch x86_64 -R ./myprogram

This didn’t seem to help.

$ valgrind --tool=memcheck ./myprogram

The output of this produced a:

Invalid free which showed where the error was.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s