softdevteam/yksom

SOMStack can cause memory leaks

ltratt opened this issue · 3 comments

At the moment, SOMStack does not overwrite Vals when they are popped/truncated (instead it simply adjusts the list's length), so rboehm probably ends up keeping alive otherwise-dead objects in some cases. We could overwrite values with Val::illegal but the nicest way of doing things would be to define a custom trace function for SOMStack. CC/@jacob-hughes

[I also wonder if Vecs have the same issue?]

I also wonder if Vecs have the same issue?

They do e.g. Vec::truncate drops items but does not overwrite the memory https://github.com/rust-lang/rust/blob/master/library/alloc/src/vec.rs#L748

smarr commented

Are there many place you use Vec? SOM doesn't have a dynamically sized data structure, I think. Except perhaps in the implementation. A quick search shows you're using it for Array

store: UnsafeCell<Vec<Val>>,

Though, arrays can't be resized in SOM, so, that shouldn't be really an issue.

The comment about Vec isn't really very yksom related: it's more something we need to think of with rboehm and friends in general. So I'm arguably guilty of raising that aspect of the problem in the wrong repo!

I have a local branch which gets rid of the Vec in Array, but we first have to convince ourselves that #172 is a good idea.