Closed ianks closed 2 years ago
Oh wow, I went to such great lengths to avoid leaks when raising errors (i.e. the whole design of returning errors to raise), and then right there at the very last hurdle there's a leak just staring me in the face.
I took a slightly different tack and (assuming no further oversights) fixed this in 8c870e3.
Awesome, thanks @matsadler. Seems to resolve the issue.
When running
ruby_memcheck
againstwasmtime-rb
's test suite, and Valgrind detected a bunch of small leaks coming from `error::raise.Turns out,
rb_raise
never frees the error message buffer so the memory for every raisedError::Error
leaks.To fix this,
error:raise
now usesrb_exc_new_str
which will allow the Ruby GC to free theRString
error message. With this change, Valgrind no longer detects the leak.