From: Takashi Iwai Subject: Re: Confusion about whether snd_pcm_poll_descriptors_revents()'s revents field is a single integer or an array Date: Mon, 02 Feb 2009 08:02:29 +0100 Message-ID: References: <20090202025021.GA20642@tango.0pointer.de> 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 mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 8AF3F243F7 for ; Mon, 2 Feb 2009 08:02:29 +0100 (CET) In-Reply-To: <20090202025021.GA20642@tango.0pointer.de> 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: Lennart Poettering Cc: ALSA Development Mailing List List-Id: alsa-devel@alsa-project.org At Mon, 2 Feb 2009 03:50:22 +0100, Lennart Poettering wrote: > > Heya! > > If we look into the pcm example how snd_pcm_poll_descriptors_revents() > is used then we can see that the revents parameter apparently is > supposed to be a single integer. (which makes a lot of sense to me) > > http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html#a33 > > However, snd_pcm_wait_nocheck() calls the same function and assumes it > is a complete array! > > http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm.c;h=74d1d1a4bd6083cd461b6d793c0ae41cca912f16;hb=HEAD#l2368 > > So what's it now? It makes more sense to me if it would be a single > fd. No, it's a bug in test/pcm.c. As documented, the API converts (fixes) each poll_fd in the given array. > The problem becomnes visible if someone writes a plugin that wants > wakeups from more than one fd because either snd_pcm_wait() using > applications start to act weirdly because the revents are not fully > initialized or snd_pcm_poll_descriptors_revents() using applications > get invalid memory accesses. > > This has become visible in the Bluetooth plugin. > > I guess nobody has written a plugin that has more than one fd to sleep > on yet, right? Right, it hasn't been a big problem just because it's a pretty rare case. Takashi