After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 427573 - [osxaudiosrc] segmentation fault
[osxaudiosrc] segmentation fault
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Mac OS
: Normal major
: 0.10.7
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-04-08 13:06 UTC by Erik Kallen
Modified: 2007-10-23 11:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that fixes the Bus Error of osxaudiosrc (1.96 KB, patch)
2007-10-21 12:48 UTC, Yun Zheng Hu
committed Details | Review

Description Erik Kallen 2007-04-08 13:06:22 UTC
when I run gst-launch-0.10 osxaudiosrc ! audioconvert ! lame ! filesink location=test.mp3

I get a segmentation fault

I tried using diffrent sinks and sources but as soon as I use osxaudiosrc the program segfaults

I ran the program using gdb this is it's output:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
[Switching to process 25484 thread 0x4e0b]
0xffff0840 in ___memcpy () at /System/Library/Frameworks/System.framework/PrivateHeaders/i386/cpu_capabilities.h:228
Line number 228 out of range; /System/Library/Frameworks/System.framework/PrivateHeaders/i386/cpu_capabilities.h has 37 lines.
(gdb) bt
  • #0 ___memcpy
    at /System/Library/Frameworks/System.framework/PrivateHeaders/i386/cpu_capabilities.h line 228
  • #1 gst_osx_audio_src_io_proc
    at gstosxaudiosrc.c line 262
  • #2 HP_IOProc::Call
  • #3 IOA_Device::CallIOProcs
  • #4 HP_IOThread::PerformIO
  • #5 HP_IOThread::WorkLoop
  • #6 HP_IOThread::ThreadEntry
  • #7 CAPThread::Entry
  • #8 _pthread_body

I'm running Mac OSX 10.4.9 compiled gstreamer from cvs
Comment 1 Yun Zheng Hu 2007-10-21 12:47:04 UTC
This bug is caused by the memcpy in gstaudiosrc.c, which is copying 4096 bytes but the actual buffer is empty. The buffer is empty because the audio device is set to the default output device instead of the default input device.

I have attached a patch that fixes the following:
 - Use the Default Input Device for osxaudiosrc instead of the Default Output.
 - Change the name of 'Device ID of output device' to 'Device ID of input device'
 - Copy the actual available bytes (which should fix the Bus Error)

Tested with the following command:
gst-launch -v osxaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=/tmp/test.ogg
Comment 2 Yun Zheng Hu 2007-10-21 12:48:55 UTC
Created attachment 97548 [details] [review]
Patch that fixes the Bus Error of osxaudiosrc
Comment 3 Yun Zheng Hu 2007-10-21 12:51:37 UTC
Comment on attachment 97548 [details] [review]
Patch that fixes the Bus Error of osxaudiosrc

>Index: gstosxaudiosrc.c
>===================================================================
>RCS file: /cvs/gstreamer/gst-plugins-good/sys/osxaudio/gstosxaudiosrc.c,v
>retrieving revision 1.10
>diff -u -r1.10 gstosxaudiosrc.c
>--- gstosxaudiosrc.c	15 Mar 2007 11:39:53 -0000	1.10
>+++ gstosxaudiosrc.c	21 Oct 2007 12:44:05 -0000
>@@ -162,7 +162,7 @@
>       GST_DEBUG_FUNCPTR (gst_osx_audio_src_get_property);
> 
>   g_object_class_install_property (gobject_class, ARG_DEVICE,
>-      g_param_spec_int ("device", "Device ID", "Device ID of output device",
>+      g_param_spec_int ("device", "Device ID", "Device ID of input device",
>           0, G_MAXINT, 0, G_PARAM_READWRITE));
> 
>   gstbaseaudiosrc_class->create_ringbuffer =
>@@ -230,11 +230,17 @@
> gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
> {
>   GstOsxAudioSrc *osxsrc;
>+  OSStatus status;
>+  UInt32 propertySize;
> 
>   osxsrc = GST_OSX_AUDIO_SRC (src);
>   if (!osxsrc->ringbuffer) {
>     GST_DEBUG ("Creating ringbuffer");
>     osxsrc->ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL);
>+    /* change the device to the Default Input Device */
>+    propertySize = sizeof (osxsrc->ringbuffer->device_id);
>+    status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
>+	&propertySize, &osxsrc->ringbuffer->device_id);
>     GST_DEBUG ("osx src 0x%p element 0x%p  ioproc 0x%p", osxsrc,
>         GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc),
>         (void *) gst_osx_audio_src_io_proc);
>@@ -255,11 +261,12 @@
>   guint8 *writeptr;
>   gint writeseg;
>   gint len;
>+  gint bytesToCopy;
> 
>   if (gst_ring_buffer_prepare_read (GST_RING_BUFFER (buf), &writeseg, &writeptr,
>           &len)) {
>-
>-    memcpy (writeptr, (char *) inInputData->mBuffers[0].mData, len);
>+    bytesToCopy = inInputData->mBuffers[0].mDataByteSize;
>+    memcpy (writeptr, (char *) inInputData->mBuffers[0].mData, bytesToCopy);
> 
>     /* clear written samples */
>     /*gst_ring_buffer_clear (GST_RING_BUFFER(buf), writeseg); */
Comment 4 Zaheer Abbas Merali 2007-10-22 16:08:10 UTC
looks good
Comment 5 Zaheer Abbas Merali 2007-10-23 08:39:09 UTC
Thanks for the patch!
Comment 6 Zaheer Abbas Merali 2007-10-23 11:57:32 UTC
Thanks for the patch!