Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » An idea for heap-checking stuffs
Re: An idea for heap-checking stuffs [message #15692 is a reply to message #15690] Sun, 04 May 2008 20:13 Go to previous message
mirek is currently offline  mirek
Messages: 14263
Registered: November 2005
Ultimate Member
mdelfede wrote on Sun, 04 May 2008 12:45

luzr wrote on Sun, 04 May 2008 18:23

mdelfede wrote on Sun, 04 May 2008 06:06

After last bug (still unresolved) of memory corruption on upp compiled under ubuntu hardy, I was thinking about some heap checking stuffs that IMO could be incorporated in upp.
So, the idea (I don't know if somebody already did it!) :

1) Set up a new building flag, for example HEAPCHECK.



Good idea to actviate heap checks in release mode.

Quote:


3) On each dynamic allocation, reserve some more bytes, some before and some after returned pointer, and fill with known data.
For example, if I need 10 bytes, I could reserve 20, like this :
DDDDDAAAAAAAAAADDDDD
     |
returned pointer here

DDDDD represent the 'spare' allocated bytes, filled with known values.



This is already done (in debug mode).


Yes ? before and after the returned pointer ? that's good !

Quote:


Quote:


4) Keep a linked list not only for freed data but also for allocated data. I know that this can slow down much the code, but.... it's just when needed for debugging.



Yep, this is also done Wink BTW, I am using these links as sentinels. And it is also used to check leaks.

Quote:


5) create 2 functions, FreeCheck() and UsedCheck() that scans the free and used allocated space and checks for values on DDDDD fileds.



MemoryCheck.



mhhhh... as far as I could see, MemoryCheck does a check on freed blocks, and only on small allocs... or am I wrong ?
Does it check also allocated blocks integrity ?



Sorry, it is in fact "MemoryCheckDebug". It calls basic MemoryCheck and then goes through the list.

Quote:


That's very interesting... but how do you see the serial number and how do you set breakpoint ?



You should see breakpoint serial number in the .log.

You can set it using "MemoryBreakpoint" function or using --memory_breakpoint commandline option. However, this is not very helpful in our Ubuntu problem as both can get active only AppInit...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: rvalue vs Pick
Next Topic: If we are going to do debugger in Linux
Goto Forum:
  


Current Time: Wed Jul 02 03:47:10 CEST 2025

Total time taken to generate the page: 0.03451 seconds