kyren / gc-arena

Incremental garbage collection from safe Rust
Creative Commons Zero v1.0 Universal
438 stars 36 forks source link

Crash from integer overflow #44

Closed dragazo closed 1 year ago

dragazo commented 1 year ago

I'm building a language runtime project that will be running long-term on an embedded device, which means I need to make frequent garbage collection passes due to very limited memory. With long-running projects, I've been getting an integer overflow crash during garbage collection, specifically here.

It looks like remembered_size is just incremented by some possibly nonzero quantity every collection pass and never decreases. Worse, my user-level program for testing just allocates some things in GC up front and then doesn't do any GC things after that aside from collection from the runtime executor. So the fact that it crashes eventually (after like 10-20 mins) sounds like collect is actually compounding the allocated/swept amount into a total over and over until you call it one too many times and crashes from overflow.

This issue is on the up-to-date master branch.