|
From: | Bas Wijnen |
Subject: | Electric fence and valgrind |
Date: | Tue, 05 Oct 2004 10:23:38 +0200 |
User-agent: | Mozilla Thunderbird 0.8 (X11/20040926) |
Hi,Lately I had given up a little on the annoying bug I wrote about before. But now I have a new idea. Since it's probably a buffer overrun problem or something, I want to treat it the same as I would with an application in GNU/Linux: with electric fence and valgrind.
For people who don't know them: Electric fence is a malloc-replacement which allocates two pages for every malloc, and returns the bytes you asked for at the end of the first one. The second page is set to unreadable so it'll segfault if used.
Valgrind seems more sophisticated, although I don't know how it works internally. It keeps track of memory initialisation and malloc/free, and warns (and optionally starts gdb) when using uninitialised memory, doing a double free, etc.
Both these tools are very useful for finding bugs which usually show up later than they occur (that is, you get a segfault in free, for example, because there was a buffer overrun somewhere before.)
Of course the problem is that valgrind is Linux-specific, and electric fence needs a POSIX program (or at least a normal malloc implementation) to work. And nothing like that is running when wortel and task are started.
Now valgrind would probably be much more useful, but also much harder to make. So I was planning to start with electric fence. For task it should be quite easy to implement, by replacing the current malloc.c. However, I think the problem is in wortel. Since wortel currently owns all memory, it is not possible to make pages unreadable. So I have a few questions:
If wortel would grant all the pages to physmem and then pagefault, would sigma0 remap the page back to wortel? And if physmem had mapped it to wortel with no permissions? Can wortel change its pager (to the nilthread perhaps) to avoid it (or to report it)?
And more importantly: Does anyone know how valgrind works internally, and can that method be used for debugging wortel?
Thanks, Bas
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] | Current Thread | [Next in Thread] |