|
From: Samofatov, N. <NSa...@br...> - 2004-07-29 19:07:11
|
Hi, Nicholas, Robert! Big thanks for your help. > > In this case I marked mmap'd block with=20 > VALGRIND_MALLOCLIKE_BLOCK. If=20 > > I do not mark the block message persists, but says block is not=20 > > stack'd, alloc'd or free'd. > > > > I have a couple questions. > > 1) Is writing suppressions right way to deal with the problem I'm=20 > > having? Or I should be marking my extents somehow? > > 2) Is my approach of interfacing with Valgrind generally correct? >=20 > Off the top of my head, your basic approach seems to be=20 > right, but I haven't checked the details thoroughly. Have=20 > you got the redzones right? > If you have, for example, a 100-byte payload and 4-byte=20 > redzones, you'll need a 108 byte block (plus any extra admin=20 > words used by your allocator, but you don't need to tell=20 > Valgrind about that. I'm doing it right way, thanks. I've looked up the examples. > You shouldn't be using suppressions here, if everything was=20 > done right it should just work. Got it, thanks. > If I were you, I would pull the memory allocator out into the=20 > smallest possible program, and experiment with that. I find=20 > that a good technique in general when experimenting with an=20 > unfamiliar language feature or something like this, because=20 > it's much easier to work out what's going on when it's not=20 > buried inside something larger. I tried to execute allocator unit tests under Valgrind and they all passed without a hitch. Memory corruption detection also seems to work quite fine for them. But if I run Firebird server I'm still getting lots of bogus errors. Now I think that most probably I'm doing something wrong with pools hierarchy (Firebird pools may be enclosed into each other). Working on this. Another question - what should I do to get stacktraces associated with blocks from pools in Valgrind memcheck output? Basically, if I write to the red zone of a small block allocated from the pool I'm getting stack trace for big block it was sub-allocated from. Is this expected or I'm doing something wrong? One more question, do I really need to track Valgrind handles and call VALGRIND_DISCARD when block becomes redefined? Or Valgrind will free old block definition and stacktrace when I reallocate memory area and mark it again with some macro such as VALGRIND_MEMPOOL_ALLOC? Nickolay |