afreeall crashes; impossible to debug memory leaks
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mksh |
Fix Released
|
Low
|
Unassigned |
Bug Description
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.
I committed some amount of DEBUG_LEAKS code. Please test that enabling it doesn’t introduce any new bugs, and secondarily, that enabling it frees all fds and memory before the shell exits in all situations.