[Home]

Summary:ASTERISK-20786: Taskprocessors can leak memory
Reporter:Mark Michelson (mmichelson)Labels:
Date Opened:2012-12-12 10:36:39.000-0600Date Closed:
Priority:MinorRegression?No
Status:Open/NewComponents:Core/General
Versions:SVN 1.8.19.0 10.11.0 11.1.0 13.18.4 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Taskprocessors work by having tasks pushed into them along with a pointer to some data. Since the task is handled in a separate thread from where the task was pushed, the task data is always heap-allocated.

This task data is freed by the task once it has finished doing whatever processing is necessary. This is sufficient for the general majority of the time.

However, when a taskprocessor gets shut down, any tasks currently queued in the taskprocessor will not have their task data freed since the tasks themselves will not be run. Currently, taskprocessor shutdown tends to correspond with Asterisk shutdown, so if there is any leaked memory, it is reclaimed by the kernel anyway.

I propose that the taskprocessor API needs to be changed so that ast_taskprocessor_push() has a new parameter, a pointer to a "free" function. This free function is intended to free the allocated task data. This function will be called automatically by the taskprocessor after processing a task so that tasks themselves are no longer responsible for freeing the task data. In addition, during taskprocessor shutdown, the task data can be freed when the task queue is emptied out.

Discussion will need to happen to determine if this change is important enough to allow for an API change in released versions of Asterisk. I consider this problem to be very minor at the moment and so this should really go into trunk only.
Comments: