afreeall crashes; impossible to debug memory leaks

Bug #1106116 reported by Thorsten Glaser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Released
Low
Unassigned

Bug Description

Forwarded from: https://android-review.googlesource.com/50201

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.

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

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.

Changed in mksh:
status: Confirmed → In Progress
Revision history for this message
Thorsten Glaser (mirabilos) wrote :

mksh R42 contains code protected by #ifdef DEBUG_LEAKS (enabled #ifdef DEBUG) to handle this.

For Android, defining DEBUG_LEAKS (but not DEBUG, never in production!) is probably sensible, but *only* after this has been tested to ⓐ not crash, ⓑ not leak, and ⓒ the exclusion of mksh in the malloc checker is reversed (though ⓒ can be done after defining DEBUG_LEAKS). I will try to set up a new VM with AOSP and submit an update of mksh soonish (this time *buntu 10.04 as building AOSP on Debian is nigh impossible and changes every time I try).

Changed in mksh:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.