It's not actually safe to call callbacks in modules without ref/unref count. So the ast_moh_start/stop callback functions should all do this.
file:
I should also add res_musiconhold has some reference counting already, and you can not 100% solve it, you can only reduce the potential for the issue, without completely rearchitecting the way modules work/unload/load/are used
because an unload could already be in progress
and you also can't module ref in ast_moh_start, because you don't have the module, so now you need to extend it to add the ability to record the module as well
(I think some kind of generic try to execute callback if it exists, and increment ref++ which requires mod ptr is needed)
You must be