One of the typical problems with implementing an allocator is that all sorts of memory failures in programs get attributed to the allocator. That's because messing up heap memory somewhere in a program or library usually messes up the allocator state even if it is implemented correctly. For several months now, we have been trying to track down and fix a very nasty memory corruption issue in Beast (#340437), which could be hunted down to rare and racy triggering with GSlice enabled, but not with G_SLICE=always-malloc set. Valgrind's memchecker didn't help with this particular Beast bug and couldn't possibly track all invalid GSlice uses. So i sat down to implement a slice address and size validator to catch the most frequent GSlice misuses. The debugging validator consists of a flat fixed-size hashing tree with fairly big prime-sized nodes and binary searchable arrays to manage collisions in the hash buckets. This structure avoids circular dependencies with GSlice (like GHashTable and GTree would have it) an
More
Support this project and others with 1-click micro-donations
