Ethereal-dev: [Ethereal-dev] Memory allocation audit, janitor project, EMEMification of dissec
List,
In my crusade to refactor all the sub-optimal memory management APIs
into EMEMified functions (memory allocations that are automatic free()
and have either a packet or capturefile allocation lifetime)
I start to see that for the less well-maintained (i.e. not core
TCP/IP, NAS or Telco protocols) there are memleaks and suboptimal code
all over the map.
Memleaks come in two kinds :
The ones that are obvious, where memory is allocated temporarily
during a single packet decode and never released
and non-obvious ones where memory is allocated but "forgotten" due to
an exception being raised.
This reinforces my belief that we really should over time rip out all
glib code and replace it with our own APIs.
Gerald, maybe we should start a Janitor project? Where people can chip
in and do reviews and look for the more obvious issues and at the same
time get familiar with the code? This would be a good starting point
for someone wanting to get into developing ethereal software.
(This is a HUGE amount of work and i dont think i can realistically do
this on my own).
The task is pretty easy, especially if one only focuses on the obvious
memleaks and mem allocation uses, leaving the more hairy or difficult
to trace allocation lifetimes until later.
Im willing to mentor anyone being new to the ethereal source code
wanting to help out.
Gerald, what about an ethereal-janitor sub project and mailing list?
First item I would propose
Grep for g_malloc() in all the dissectors and pick them one by one,
trace the allocation, lifespan and release of all memory and replace
all the trivial ones one by one with ep/se_alloc().
Do the trivial ones with obviously correct fixes first and leave the
others for later.
Anyone want to chip in? There are still 140 g_malloc()s left in
epan/dissectors and if my current experience is worth anything
probably half of them will have obvious memleaks (i.e. never g_free())
and virtually all the others have non-obvious ones (exception raised
between g_malloc() and g_free() and no CLEANUP_PUSH or simiar kludge)
raise your hand if you want to help out, its pretty boring work but
should really be done.
help in this very welcomed.
best regards
ronnie sahlberg