[pulseaudio-discuss] [PATCH v5 39/39] bluetooth: Revive module-bluetooth-discover

João Paulo Rechi Vita jprvita at gmail.com
Tue Oct 8 16:19:42 CEST 2013


On Sun, Sep 29, 2013 at 1:39 PM, Tanu Kaskinen
<tanu.kaskinen at linux.intel.com> wrote:
> On Tue, 2013-09-24 at 19:45 -0300, jprvita at gmail.com wrote:
>> +void pa__done(pa_module* m) {
>> +    struct userdata *u;
>> +
>> +    pa_assert(m);
>> +
>> +    if (!(u = m->userdata))
>> +        return;
>> +
>> +    if (u->bluez5_module)
>> +        pa_module_unload(m->core, u->bluez5_module, true);
>> +
>> +    if (u->bluez4_module)
>> +        pa_module_unload(m->core, u->bluez4_module, true);
>
> This crashes when shutting down the daemon, because when the daemon
> unloads all modules, module-bluez*-discover gets unloaded before
> module-bluetooth-discover, so the y->bluez5_module and u->bluez4_module
> pointers become stale. I see two ways of fixing this: add a hook that is
> fired when modules are unloaded and use that hook in
> module-bluetooth-discover to drop the reference to the unloaded module,
> or unload module-bluetooth-discover immediately after loading
> module-bluez5-discover and module-bluez4-discover. The second solution
> is of course much simpler, but I proposed that already earlier, and you
> didn't like that.
>

It doesn't crash (and that's what I'm experiencing here) because
pa_module_unload() will look for that module pointer in its internal
hash of modules before trying to unload it. I agree we are left with a
stale pointer, but as long as we don't dereference it, we should be
fine.

-- 
João Paulo Rechi Vita
http://about.me/jprvita


More information about the pulseaudio-discuss mailing list