stephenrkell / liballocs

Meta-level run-time services for Unix processes... a.k.a. dragging Unix into the 1980s
http://humprog.org/~stephen/research/liballocs
Other
218 stars 26 forks source link

Support running under Valgrind #92

Open stephenrkell opened 8 months ago

stephenrkell commented 8 months ago

Since Valgrind shadows memory eagerly, it blows up when we allocate a large MAP_NORESERVE region, because it tries to eagerly shadow it.

For a long time, we used memtables everywhere and I could not see a reasonable fix. But now we don't use them much... the pageindex is our only huge unreserved mapping.

I had long thought about a special "Valgrind build" that uses a different data structure for the pageindex. However, probably something simpler and cleaner will suffice: map the pageindex lazily. We can install a SIGSEGV handler and do that (and/or how slow would an ensure_mapped() call be at pageindex manipulations?). It works only because we explicitly place all mappings, so we can ensure we never map something else in a place where we may later need to map the pageindex.

stephenrkell commented 8 months ago

Having said that, Valgrind itself tries to own the memory map and so we may have a tussle on our hands. Someone needs to try this... probably me, for now.