|
From: Nicholas N. <nj...@cs...> - 2006-09-03 02:37:32
|
On Sat, 2 Sep 2006, Gurganus, Brant L wrote: > It is probably outside the scope of Omega and Memcheck, but there are > resource allocators at higher levels than malloc/free pairs that would be > nice to check, preferrably in an easily extensible fashion. I'd like to > see a way of specifying resource allocators and deallocators that are from > somebody else's code. For example, I'd like a tool that handles finding > unmatched malloc/free, fopen/fclose, open/close, > XOpenDisplay/XCloseDisplay, etc. That's a good idea for a separate tool. I think this would make a great project for someone. I don't think it would be that difficult. I can imagine having a configuration file where you name the alloc/dealloc function pairs. Those examples all follow the following pattern in their type signatures: token alloc(...) ... dealloc(token t) You'd need a way to handle cases where alloc() fails (eg. open() returns -1). You might also need to handle some slight variations on the above (eg. an extra arg to the dealloc function). You'd implement it in Valgrind using function wrapping to know when the alloc/dealloc functions are called. I think Coverity's tools can do this kind of thing, but they use a completely different technique to Valgrind -- static source-level analysis using model checking, as opposed to dynamic binary analysis. Nick |