From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Strange div-by-zero in alsa-lib 1.0.20's snd_pcm_mmap_begin() Date: Mon, 17 Aug 2009 08:49:34 +0200 Message-ID: References: <604760770908161524w207a4a44m72793fa9438c2ef4@mail.gmail.com> 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 (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 0146D245E9 for ; Mon, 17 Aug 2009 08:49:34 +0200 (CEST) In-Reply-To: <604760770908161524w207a4a44m72793fa9438c2ef4@mail.gmail.com> 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: Daniel Chen Cc: alsa-devel List-Id: alsa-devel@alsa-project.org At Sun, 16 Aug 2009 18:24:35 -0400, Daniel Chen wrote: > > Hi, > > In https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/412677 > we're debugging an issue where snd_pcm_mmap_begin(), at line 6409 with > > *offset = *pcm->appl.ptr % pcm->buffer_size; > > appears to have pcm->buffer_size == 0. What's the correct approach in > handling this corner case? We could add a sanity check in the function, of course. But relying on it doesn't sound nice. At least, the caller should be surely at the certain state that the buffer has been set up, i.e. checking whether snd_pcm_state() returns SETUP or better condition. Takashi