[pulseaudio-discuss] [PATCH] Plug some memory leaks and an invalid read

Colin Guthrie gmane at colin.guthr.ie
Tue Aug 16 02:50:50 PDT 2011

'Twas brillig, and Colin Guthrie at 16/08/11 10:08 did gyre and gimble:
> Just out of curosity, is this what is causing:
> I: [pulseaudio] module.c: Unloading "module-alsa-card" (index: #4).
> D: [pulseaudio] protocol-dbus.c: Interface org.PulseAudio.Core1.Device
> removed from object /org/pulseaudio/core1/sink0
> D: [pulseaudio] protocol-dbus.c: Interface org.PulseAudio.Core1.Sink
> removed from object /org/pulseaudio/core1/sink0
> E: [pulseaudio] core.h: Assertion 'pa_object_refcnt(pa_object_cast(o)) >
> 0' failed at ./pulsecore/core.h:184, function pa_core_assert_ref().
> Aborting.
> Aborted

It's not.

This is caused by a pa_core_assert_ref inside an unlink function....

It seems this is not valid when shutting down the server as
pa_core_unref() unrefs itself (thus ref-cnt==0), calls
pa_module_unload_all() which in turn triggers unlink hooks.

So two solutions:

1. Remove such asserts from those hooks that need it.
2. Re-ref/unref the core inside it's free function.
3. Call pa_module_unload_all() && pa_scache_free_all() before calling

2 is hard to do (can't ref something with a ref-cnt already at 0) and 1
is a bit ugly as it imposes different rules on you (i.e. if the core
state is shutdown, then don't use the core), so I think 3 is the right



Colin Guthrie

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

More information about the pulseaudio-discuss mailing list