yjit
yjit copied to clipboard
Memory leak with const_set
The current opt_setinlinecache implementation invalidates the block for the corresponding opt_getinlinecache, and one could make opt_setinlinecache run by setting any constant. Apps that use Module#const_set at runtime will leak memory because of this. The following script eventually triggers [BUG] out of executable memory.
$VERBOSE = nil
Const = 0
def get
Const
end
loop do
get
Object.send(:const_set, :Const, 0)
end
Three thoughts:
- This would also be fixed by a mechanism to throw away executable code when we hit the limit.
- We could technically monitor how many times a given
opt_getinlinecachegets recompiled and eventually stop recompiling? May not be practical since we currently don't invalidate per inline cache? - I would like you to engage in an exercise. Every time you report a problem, try to also suggest one or more potential solutions, ideally as simple and efficient as possible.
Is this still relevant? The insn sequence is different today, just opt_getconstant_path, and it seems like I can't reproduce the issue with that script.