| 1 |
------------------------------------------------------------------------------- |
| 2 |
$Id: TODO,v 1.33 2001/07/12 23:12:13 gray Exp $ |
| 3 |
------------------------------------------------------------------------------- |
| 4 |
|
| 5 |
HEAP OPERATIONS: |
| 6 |
|
| 7 |
- realloc should look on either side (preferring above of course) for |
| 8 |
free bblocks and absorb them |
| 9 |
- find free section we can use |
| 10 |
- remove from free list(s) |
| 11 |
- rewrite admin chunks for used |
| 12 |
- rewrite admin chunks for left-overs (if there are any) |
| 13 |
- readd left-overs to free list (if there are any) |
| 14 |
- when the last element in a dblock is freed, the block should be freed. |
| 15 |
- presents problems with maintaining the dblock-admin slots |
| 16 |
- probably requires a new pointer admin tree |
| 17 |
- have the ability of limiting the size of the heap |
| 18 |
- simulate heap boundary |
| 19 |
- do number of bytes (maybe take k,K,m,M extensions) |
| 20 |
- have start do number of bytes also? |
| 21 |
|
| 22 |
------------------------------------------------------------------------------- |
| 23 |
|
| 24 |
NEW HEAP ADMIN: |
| 25 |
- need a list of block-ids: |
| 26 |
- flag/size (bblock/free/dblock/external/unused) |
| 27 |
- 1... = bblock # bytes allocated (max alloc = 2gb) |
| 28 |
- 01... = free # bblocks till used block |
| 29 |
- 00... = where ... > 1 = dblock # bits/# used |
| 30 |
- external == 00...1 (all zeros then a 1) |
| 31 |
- unused == 00...0 (all zeros) |
| 32 |
- pointer: for info-block if used, next free if not |
| 33 |
- next pointer for free-list (is this necessary?) |
| 34 |
- pointer to [first] info block below |
| 35 |
- need to search on pnt to find allocations: file, line, size |
| 36 |
- key: pnt |
| 37 |
- data: |
| 38 |
- (char *)file/ret-addr (or next->) |
| 39 |
- (short)line-number (0 if ret-addr) |
| 40 |
- (short)size: # dblock-bytes/bblocks |
| 41 |
- [pointer to bblock to go faster, ifdef] |
| 42 |
- [iteration # when allocated] |
| 43 |
- [iteration # when last touched] |
| 44 |
- [time when allocated] |
| 45 |
- [time when last touched] |
| 46 |
- [memory crc to track changes, need ~MD5 (token?)] |
| 47 |
- [some sort of use counter] |
| 48 |
- idea is to keep the info struct |
| 49 |
around even the section was freed. |
| 50 |
That way we can track how many times a |
| 51 |
pointer was returned |
| 52 |
- time could be global or elapsed |
| 53 |
- always save start-time and dump it on shutdown if LOG_STAMP |
| 54 |
- ifdef the global or elapsed |
| 55 |
- ifdef the last-touched information |
| 56 |
- time info when LOG_STAMP |
| 57 |
- iteration information need a token: LOG_ITERATION |
| 58 |
- need to separate the allocations of the trees, different data sizes |
| 59 |
- either ignore the external bblocks and the ones for the tree |
| 60 |
allocations or account for them via careful recursion |
| 61 |
- still need free lists of bblocks/dblocks |
| 62 |
- maybe maintain the bblock free list (sorted by # blocks) in |
| 63 |
a skip-list for easy location, or walk free-list |
| 64 |
- with fence overruns, dump the pointer info on either side |
| 65 |
- easy with allocation tree |
| 66 |
- maybe have a #ifdef to define how many pnts on either side |
| 67 |
|
| 68 |
------------------------------------------------------------------------------- |
| 69 |
|
| 70 |
CHECKING: |
| 71 |
|
| 72 |
- maybe have a type as the first argument to message |
| 73 |
- can be error,trans,admin,debug,etc. |
| 74 |
- this spits out a starting label to all messages: |
| 75 |
trans: checking heap |
| 76 |
admin: need 1 bblocks |
| 77 |
- check in heap_check the cleared space above each allocation instead of |
| 78 |
only the fence posts |
| 79 |
- maybe add another debug level which stores crc information about internal |
| 80 |
heap structures and verifies it during run time. slow, slow!! |
| 81 |
- maybe add crc information about each memory block into the admin |
| 82 |
structure and then be able to dump which blocks have changed |
| 83 |
- maybe add 'use-mprotect' token to allow the user to access only |
| 84 |
user-allocated pages |
| 85 |
- a _big_ project could involve hacking gcc to allow some sort of heap |
| 86 |
checking of every memory reference. |
| 87 |
- watch for non-contiguous memory and mark those blocks as external |
| 88 |
- have some sort of EXTERNAL flag |
| 89 |
- make sure checked/freed/realloced/etc. pointers are not in that area |
| 90 |
- we may need to round sbrk() calls if someone else did not do a |
| 91 |
page-size call (see get_bblocks in chunk, need non-alloc flag) |
| 92 |
- think of ways we can reorganize the heap and move allocations around |
| 93 |
since problems sometimes pop-up with different heap organizations: |
| 94 |
|
| 95 |
- pick a random slot from the free-list not just the first entry |
| 96 |
- add new list of dblocks in reverse order to the free-lists or |
| 97 |
randomly disperse |
| 98 |
- maybe when allocating for a block of X bits, get 2 blocks or |
| 99 |
some allocation factor |
| 100 |
- maybe some sort of compact heap orientation like ndt organization. |
| 101 |
- need a different dblock admin maintenance or |
| 102 |
- need to allocate max dblock-admin for every block |
| 103 |
- maybe generate some magical value which corresponds to the |
| 104 |
orientation because you want to be able to reproduce |
| 105 |
the error (bsd random?) |
| 106 |
- probably need an internal randomizer with log-able seed |
| 107 |
value and the ability to set the seed |
| 108 |
|
| 109 |
------------------------------------------------------------------------------- |
| 110 |
|
| 111 |
DOCUMENTATION: |
| 112 |
|
| 113 |
- add more to the debugging section: |
| 114 |
- use of MALLOC_START because a failure is found at some point |
| 115 |
to find the last malloc call |
| 116 |
- use of MALLOC_FUNC_CHECK by inserting dmalloc.h and FUNC_CHECK on |
| 117 |
- need to make sure the manual works for the brand new user |
| 118 |
- need an overview early on about its purpose (at a very high level) |
| 119 |
- need a section to explain all the error codes |
| 120 |
- put in a section about other malloc libraries and commercial versions |
| 121 |
|
| 122 |
------------------------------------------------------------------------------- |
| 123 |
|
| 124 |
TESTING / STATISTICS: |
| 125 |
|
| 126 |
- maybe use the new gnu testing code (GCT) |
| 127 |
- general tons of small blocks and watch for dblock_admin entry leak |
| 128 |
like with large ndb_shell scripts |
| 129 |
- maybe a program that would try a standard set of tests on a number of |
| 130 |
different combinations of debug-values to look for dependencies. |
| 131 |
|
| 132 |
------------------------------------------------------------------------------- |
| 133 |
|
| 134 |
GENERAL: |
| 135 |
|
| 136 |
- add display_pnt calls mostly everywhere display_where calls in chunk. |
| 137 |
- maybe show the upper-end of a pointer if it is over fence post |
| 138 |
- need to pass size into log_error_info |
| 139 |
- maybe with no 'log-unknown' token, don't print ANY info about |
| 140 |
non-file-line pnts |
| 141 |
- maybe have some sort etext support for systems that don't have it? |
| 142 |
- etext (heap-start?) |
| 143 |
- end (heap-end?) |
| 144 |
- maybe have some sort of memory-stack support: |
| 145 |
- malloc_push_location("foo"); |
| 146 |
- malloc_pop_location("foo"); |
| 147 |
- have a maximum ~100 entry stack |
| 148 |
- count how deep we are and if we go over don't store but track so |
| 149 |
when we drop below 100 it will be correct info |
| 150 |
- if we are at an unknown spot, display the top of the stack |
| 151 |
- maybe some sort of cheap crc on memory in non-freed memory sections so |
| 152 |
you can see what portions of memory changed (check tripwire) |
| 153 |
- maybe provide support for reference counts on allocations: |
| 154 |
- have a call which along with malloc/realloc, increments the |
| 155 |
reference count of the node (maybe duplicate_pointer) |
| 156 |
- free will decrement the reference count and free if 0 |
| 157 |
- have a call which reports on the reference count of the node |
| 158 |
- may need additional admin space |
| 159 |
- debug token? |
| 160 |
- maybe have bit in allocation struct somewhere that it is a string and |
| 161 |
maybe have a checking level/value that runs though the strings |
| 162 |
and makes sure they have a NULL in them. |
| 163 |
- token 'check-string' or something |
| 164 |
- should only happen if alloc-blank used |
| 165 |
- could be dangerous if folks are changing 'type' of allocation |
| 166 |
from string to ... |
| 167 |
- maybe some special strdup flag or something |
| 168 |
- write perl script to summarize the memory usage per file. |
| 169 |
- for fence underflow, print out the pointer below's info and for fence |
| 170 |
overflow the pointer above's info |
| 171 |
- handle memalign, valloc, maybe some form of mallopt |
| 172 |
- maybe mallopt could be mapped into dmalloc_debug() |
| 173 |
|
| 174 |
- maybe an environment variable to designate which program(s) you want to |
| 175 |
debug. found with strstr. |
| 176 |
- or could use .mallocrc entry |
| 177 |
- could have program:tag entries for default behavior in program |
| 178 |
- requires knowing the argv[0] argument |
| 179 |
- add a recalloc function. I guess it is available under SGI. |
| 180 |
|
| 181 |
------------------------------------------------------------------------------- |
| 182 |
|
| 183 |
- should the free and alloc-blank tokens write the address % 256 into |
| 184 |
bytes instead of a constant '\305' |
| 185 |
|
| 186 |
- it would slow it down a bit |
| 187 |
- maybe some token/option? |
| 188 |
- \305 is recognizable however |
| 189 |
|
| 190 |
- I've considered adding the mprotect features which would signal if |
| 191 |
code READ into certain areas (writing is easy with magic values). |
| 192 |
This causes problems since most (all?) mprotect implementations work |
| 193 |
with page-size resolutions which means that every allocation (8 byte |
| 194 |
string) would require 8+pagesize (often > 4096 bytes). Anyone have a |
| 195 |
easier way of accomplishing this? |
| 196 |
|
| 197 |
------------------------------------------------------------------------------- |
| 198 |
|
| 199 |
I would like to blacklist a list of 'ra=0x4013195c'. I would be *very* |
| 200 |
usefull to shut-up numerous leaks from standard C library. Is there a |
| 201 |
way to do that ? |
| 202 |
|
| 203 |
------------------------------------------------------------------------------- |
| 204 |
|
| 205 |
but I'd like the extra feature of being able to SIGUSR1 a running |
| 206 |
program and get a memory footprint during the main cycle (I'll add |
| 207 |
this feature myself to dmalloc if I can get it working). |
| 208 |
|
| 209 |
------------------------------------------------------------------------------- |
| 210 |
|
| 211 |
It would be nice to have dmalloc_examine return good information from |
| 212 |
random pointers: |
| 213 |
|
| 214 |
- whether in heap or not |
| 215 |
- in use or not |
| 216 |
- free, realloc'd, calloc'd, etc. |
| 217 |
- more than 1 file/line/ra for alloc, realloc, free locations |
| 218 |
|
| 219 |
------------------------------------------------------------------------------- |