afreeall crashes; impossible to debug memory leaks
Forwarded from: https:/
When trying to use leak debugging, mksh doesn’t exactly shine: its area allocator does have an afreeall function, but trying to use it makes the shell crash. This is a true bug, albeit of low priority, that must be fixed.
Other than that, there are a handfull of memory leaks to plug. Most of them seem to occur either in APERM or in some ATEMP that is cleaned after the current command has run anyway, so they do not impact normal operation – exiting mksh will let the OS reclaim all memory anyway – but they hinder leak debugging. I think this can only be done once we can (and do, in an #ifdef DEBUG codepath) safely call afreeall upon exit.
Valgrind is also a tool to use. (I’m using it, but only the access checker, with leak checking turned off.)
This is far from trivial, and volunteer help from experts is welcome.