[squeak-dev] Building (Linux) VM - with segfaults. that point to audio

Brad Fuller bradallenfuller at gmail.com
Tue Nov 18 23:12:48 UTC 2008


On Tue, Nov 18, 2008 at 10:22 AM, Brad Fuller <bradallenfuller at gmail.com> wrote:
> The problem might be that arrayIndex is 32bit and it is used to
> calculate *samples which is 64bit. This would be a problem if
> arrayIndex has bit31 set.
>
> EXAMPLE: If arrayIndex comes in with bit31 set (e.g. 0x911f13fc),
> which is negative, the top bit is extended when *samples is
> calculated. samples becomes 0xffffffff911f13fc.(actual values while
> debugging)
>
> Perhaps the cast (void *)arrayIndex was to fix that.
>
> Here's the function... I'm referencing lines 5 and 6 of the function:
>
> ====================
> 1 static sqInt  sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt
> arrayIndex, sqInt startIndex)
> 2 {
> 3  if (output_handle)
> 4    {
> 5      void *samples= (void *)arrayIndex + startIndex * output_channels * 2;
> 6      int   count=   snd_pcm_writei(output_handle, samples, frameCount);
> 7      if (count < frameCount / 2)
> 8       {
> 9         output_buffer_frames_available= 0;
>        }
>      if (count < 0)
>        {
>          if (count == -EPIPE)    /* underrun */
>            {
>              int err;
>              snd(pcm_prepare(output_handle), "sound_PlaySamples: snd_pcm_prepare");
>              return 0;
>            }
>          fprintf(stderr, "snd_pcm_writei returned %i\n", count);
>          return 0;
>        }
>      return count;
>    }
>  success(false);
> ============
>
>
> Does that seem right to you all?
>
> Maybe sqInt never gets to be long long?  sqMemoryAccess.h defines:
>
> #if defined(SQ_IMAGE32)
>  typedef int sqInt;
>  typedef unsigned int usqInt;
> #elif defined(SQ_HOST64)
>  typedef long sqInt;
>  typedef unsigned long usqInt;
> #else
> # if (SIZEOF_LONG_LONG != 8)
> #   error long long integers are not 64-bits wide?
> # endif
>  typedef long long sqInt;
>  typedef unsigned long long usqInt;
> #endif


oh... I should add I see warnings during compilation. This is applicable:

platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c: In function
'sound_PlaySamplesFromAtLength':
platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c:204: warning: cast to
pointer from integer of different size

Line 204 in this error is line 5 above

-- 
Brad Fuller



More information about the Squeak-dev mailing list