Store evicted cache entries to avoid dropping in-use mappings#759
Store evicted cache entries to avoid dropping in-use mappings#759ChrisDenton wants to merge 1 commit into
Conversation
|
So the immediate thought I had when the issue came up was that maybe we should just wholesale duplicate the cache with every call to |
|
Hm, duplicating everything would be a bit much I think? Debug info can be quite large. That being so, I think we need a reference count somewhere to avoid dropping memory that's in use. But it could be on the |
|
Or, hm, maybe we can store the library id that is in use and restore them by pushing to the cache normally. Something like this: ChrisDenton@8bcfb50? |
|
I did mean something trying to preserve identity without like redoing mmaps, yes. |
988d6a8 to
b72836b
Compare
This makes recursively calling `resolve` safe even if the cache is filled.
|
Ok, I've taken another go at it. This time it stores then restores evicted cache entries. (btw the macos runner is still intermittently playing up) |
This is one approach to workaround #758.
A reference count is kept with each mapping so we know if it's still in use. If it is then we never drop it from the cache. This will work for recursion up to
MAPPINGS_CACHE_SIZE(aka 4). After that it will fail to add new mappings. Which means it will effectively act as though loading the debug information failed (i.e. it won't resolve any symbols).The disadvantage of this approach is it does potentially break programs that worked before. If you only use a symbol before you recurse (and never afterward) then you could previously do so infinitely*. I'm not sure that's a useful property though and tbh is a bit dubious soundness wise anyway (but probably works in practice).
Other possible approaches include making some kind of linked list of lru caches or redesigning the API so that
Symbolcan properly hold (and drop!) a reference to its cache entry.