danielpclark / rutie

“The Tie Between Ruby and Rust.”
MIT License
940 stars 62 forks source link

return st_retval from rb_hash_foreach #102

Closed danlarkin closed 5 years ago

danlarkin commented 5 years ago

rb_hash_foreach wants a callback that returns an st_retval.

Returning () causes (AFAICT?) a read from uninitialized memory, which means who-knows-what happens when iterating. I wasn't able to reduce this to a repeatable test case, but I have been able to observe this happening in real code, and this commit does appear to fix it.

I've hard coded a return of st_retval::Continue so as to not break the current API, but maybe rutie::Hash should have a new method that allows controlling it.

danielpclark commented 5 years ago

This is awesome! There are a few tests in Rutie that aren't done by the docs. Could you write a test that shows it working. You don't need to prove edge cases, just that it works. I think when we get to the “new method that allows controlling it” then we can test for the edge cases. I'm in agreement with you on adding that.