Removing a facility leaves blank lines in the config
tomaw opened this issue · comments
After a bunch of playing with a local test instance and looking over the source, I couldn't notice anything obviously wrong in the code … so I made it use mowgli patricias instead of dictionaries, and those work just fine. I wonder just how broken the mowgli dictionary code is.
I discussed mowgli dictionaries with amdj who concluded they work fine. Investigating a little more deeply, it turned out that mowgli's heap allocator let a use-after-free in our code go unnoticed:
Lines 578 to 579 in 42f57d6
(This is not an issue with mowgli patricias as these keep a copy of the key instead.)
I've let amdj know about how mowgli's heap allocation behaviour caused us a hard-to-notice error, and we've agreed to make this optional in libmowgli-2.
Additionally, strcasecmp
returns int
but mowgli dictionaries need the comparator function to return long
. On some systems, these two are essentially the same thing, but generally, we can't just pass a function returning int if we expect a function returning long, or bad things will happen.
Normally, compilers will warn about this sort of thing. Of course, if you silence the warning by inserting a cast, the compiler may assume you know what you're doing and won't tell you that it'll go horribly wrong.
Line 268 in 42f57d6
(The patricia-based code avoids this issue; strcasecanon
is specifically made to be passed to a mowgli patricia.)
tl;dr: mowgli dictionaries aren't broken after all, syn's use of them is (big surprise, there).