rgbds icon indicating copy to clipboard operation
rgbds copied to clipboard

Find and fix RGBASM memory leaks

Open Rangi42 opened this issue 4 years ago • 3 comments

  • [ ] PURGE or REDEF of an EQUS symbol does not free its previous string contents.
  • [ ] Use Bison to free memory when a token is deleted
  • [ ] Files are never unmaped if a single macro or REPT block occurred within
  • To be continued

Rangi42 avatar Jan 21 '21 14:01 Rangi42

Believe it or not, but you can't free an EQUS :) I tried, and it explodes with a bunch of funny colors. The main problem is an expansion deleting itself; the solution is to ref-count strings. (This overlaps with #650.)

A large chunk of the problem is the lack of cleanup when done with assembling.

ISSOtm avatar Jan 21 '21 14:01 ISSOtm

Note that Bison's token destructors might help with this a bit.

ISSOtm avatar Apr 19 '21 09:04 ISSOtm

ASAN is enabled, but disables checking for memory leaks for now with detect_leaks=0.

Rangi42 avatar May 02 '21 17:05 Rangi42

See about using an 'std::shared_ptr aliasing constructor' for dealing with string_views that preserve the lifetime of a backing std::string (or mmap or whatever).

Rangi42 avatar Mar 22 '24 21:03 Rangi42