Conversation
A head reader owned whatever node the walk down its path reached, which for a path that stops inside a node -- or is not in the trie at all -- is a node the head's writers descend through. The next exclusive writer copied it, and the writers already made kept pointing into the copy that was then dropped; the reproducer segfaults. A value at the reader's root was borrowed from the node above it, which writers copy the same way. Keep owning the node when the path lands on one and it carries no value of its own: no writer may be at or below the reader's path, so none is inside it, and that is the common case. Otherwise copy just this entry -- its value, its subtrie, or its dangling path -- into a private node, and root the reader one byte above it.
|
This is a really serious bug and fixing it is non-negotiable. But the perf cost of the fix seems to be quite nasty. I don't have any more time to spend on this immediately. But I'll try to come up with something that is a little easier on the benchmarks. |
… squishing warnings in test
|
I'm looking at the benchmarks, and there doesn't seem to be a big impact? |
I had to add new benchmarks to make sure the affected cases in particular were hit. But when I added (had Claude add) the new benchmarks, (and cherry-picked them back to master locally), here are the results I saw: You don't need to spend any more time on this because I haven't yet validated there isn't something bogus going on. And I think I have some ideas about how to approach speeding up a fix. |
A head reader owned whatever node the walk down its path reached, which for a path that stops inside a node -- or is not in the trie at all -- is a node the head's writers descend through. The next exclusive writer copied it, and the writers already made kept pointing into the copy that was then dropped; the reproducer segfaults. A value at the reader's root was borrowed from the node above it, which writers copy the same way.
Keep owning the node when the path lands on one and it carries no value of its own: no writer may be at or below the reader's path, so none is inside it, and that is the common case. Otherwise copy just this entry -- its value, its subtrie, or its dangling path -- into a private node, and root the reader one byte above it.