Closed wiml closed 4 years ago
I wonder if this is the reason I had to use LimitSTACK=infinity for db server..
funny enough, I cannot reproduce stack overflow in parse_keystr
because I am seeing stack overflow in key_to_stream
first :)
cherry picked in c753283, thanks!
When importing a current keydump, SKS will crash (on my machine at least) due to too-deep recursion in
siglist
. This is just because there are some keys with a ridiculous number of signatures (due to vandalism/attacks, but still). Presumably any other operation that requires merging into that key will also cause the same problem, but this is the situation I found first and was easy to reproduce.This patch makes the key parsing routines tail-recursive by adding an
unfold
-like helper function. With this change SKS can import a keydump without requiring a huge stack.Presumably this change causes the allocation of a few extra cells of short-lived garbage in the key merge operation, but in testing I wasn't able to detect a performance difference (using
4.10.0+flambda
).