From: Takashi Iwai Subject: Re: External PCM hook SO is dlclosed after calling install, making it hard to have hooks in it Date: Tue, 30 Jun 2009 08:33:15 +0200 Message-ID: References: <20090629221101.GD23025@home.pavel.comp> <20090630062054.GE23025@home.pavel.comp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id E63C9103862 for ; Tue, 30 Jun 2009 08:33:15 +0200 (CEST) In-Reply-To: <20090630062054.GE23025@home.pavel.comp> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Paul Fertser Cc: Joerg Reisenweber , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Tue, 30 Jun 2009 10:20:54 +0400, Paul Fertser wrote: > > On Tue, Jun 30, 2009 at 08:09:45AM +0200, Takashi Iwai wrote: > > At Tue, 30 Jun 2009 02:11:01 +0400, > > Paul Fertser wrote: > > > I've tried to implement an external shared object to be able to > > > execute arbitrary functions on PCM device opening and closing. After > > > quite some source code reading i had an almost working but segfaulting > > > example. This segfault is because snd_dlclose is called right after > > > calling a hook install function and therefore i can't snd_pcm_hook_add > > > functions from the same shared object. To me it looks like a bug but > > > probably i just don't see how this functionality is intended to be > > > used. Takashi, git-blame showed that it's you who stuffed this dlclose > > > call that bothers me ;) > > > > Well, right now, a plugin is designed to be bound with a single PCM > > instance. That's why dlcolse is called in snd_pcm_close(). > > It looks like we're talking about different things. You seem to be > talking about external PCM plugins, i'm talking about external functions > for the "hook" PCM plugin. The code i question is in pcm/pcm_hooks.c > in function snd_pcm_hook_add_conf: > > if (err >= 0) { > if (args && snd_config_get_string(args, &str) >= 0) { > err = snd_config_search_definition(root, > "hook_args", str, &args); > if (err < 0) > SNDERR("unknown hook_args %s", str); > else > err = install_func(pcm, args); > snd_config_delete(args); > } else > err = install_func(pcm, args); > snd_dlclose(h); > } Ah, I understand now. Yes, this looks like a bug. Meanwhile, it makes another bug if we just remove it. There would be no dlclose(), then. It'd need resource tracking. A lack of dlclose is no serious bug, though. So... just removing snd_dlclose() there fixes your problem? If yes, I'll commit the fix. thanks, Takashi