cmusatyalab / gammaray

Distributed Streaming Virtual Machine Introspection
Apache License 2.0
17 stars 6 forks source link

Freeing same memory twice? #27

Open bamos opened 9 years ago

bamos commented 9 years ago

Hi @theonewolf, (cc @wenluhu)

gray-crawler is giving the following stacktrace on the gpt-test.raw image:

screen shot 2014-10-12 at 1 22 58 am

gdb indicates this problem is coming from mbr.c:mbr_cleanup_pte().

screen shot 2014-10-12 at 1 23 58 am

I added a statement to print the address of pte.pte_info to this function:

screen shot 2014-10-12 at 1 25 04 am

And indeed, the same pointer is being freed twice:

screen shot 2014-10-12 at 1 25 26 am

My naive fix is to comment this out so I can start working on the GPT code. This is obviously not the correct solution. :-)

screen shot 2014-10-12 at 1 27 34 am

screen shot 2014-10-12 at 1 31 12 am

Can you take a look at this when you get a chance? If this isn't something you can easily fix, I'm happy to take a closer look and send a patch.

theonewolf commented 9 years ago

I can fix this, probably easily. Feel free to comment out the free while you work on GPT support.

I'd say memory leaks in the crawler are low-priority overall, as the crawler is not a long-lived/long-running process.

theonewolf commented 9 years ago

Off the top of my head, setting the pte.pte_info field to NULL right after the free might be the right thing to do?

It looks like it is somehow getting reused, so maybe it then needs re-allocation (ie setting it to NULL will expose another bug). Something probably stupid happening from my end.