Hi,
I had a v4l2 camera driver with the “V4L2_MEMORY_USERPTR” type memory support and a camera source element “v4l2newcamsrc” to support this type memory.
When I running the pipeline bellow
“gst-launch v4l2newcamsrc num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=640,height=480 ! filesink location=image_640.yuv”
The image can be captured successfully.
But when the buffers are freed in the camera source element, there will always be an error message in the terminal.
*** glibc detected *** /usr/local/meego/bin/gst-launch-0.10: free(): invalid pointer: 0xb73c8008 ***
======= Backtrace: =========
/lib/libc.so.6[0x550cc1]
/usr/local/meego/lib/libgstreamer-0.10.so.0(+0x29c06)[0xb7792c06]
/usr/local/meego/lib/libgstreamer-0.10.so.0(gst_mini_object_unref+0xaf)[0xb77b94df]
.
I use gst_pad_alloc_buffer_and_set_caps() to allocate the buffer from the download element in the camera source element.
When the application exit, gst_buffer_unref (buffer) will be called to free the memory. This code case the error above after debugging with GDB.
I have two questions about that.
Thanks.
Best Regards!
Hu Gang
------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Administrator
|
On Wed, 2010-08-04 at 20:33 +0800, Hu, Gang A wrote:
> Hi, > I had a v4l2 camera driver with the “V4L2_MEMORY_USERPTR” type memory > support and a camera source element “v4l2newcamsrc” to support this > type memory. > When I running the pipeline bellow > “gst-launch v4l2newcamsrc num-buffers=1 ! ffmpegcolorspace ! > video/x-raw-yuv,width=640,height=480 ! filesink > location=image_640.yuv” > The image can be captured successfully. > But when the buffers are freed in the camera source element, there > will always be an error message in the terminal. > > *** glibc detected *** /usr/local/meego/bin/gst-launch-0.10: free(): > invalid pointer: 0xb73c8008 *** > ======= Backtrace: ========= > /lib/libc.so.6[0x550cc1] > /usr/local/meego/lib/libgstreamer-0.10.so.0(+0x29c06)[0xb7792c06] > /usr/local/meego/lib/libgstreamer-0.10.so.0(gst_mini_object_unref > +0xaf)[0xb77b94df] You've cut the backtrace too early so we can't say who called that last buffer unref. > . > > I use gst_pad_alloc_buffer_and_set_caps() to allocate the buffer from > the download element in the camera source element. > When the application exit, gst_buffer_unref (buffer) will be called to > free the memory. This code case the error above after debugging with > GDB. > > I have two questions about that. > 1. Which element is responsible for the memory allocation when > call “gst_pad_alloc_buffer_and_set_caps()” in camera source > element in my pipeline. An element downstream (you didn't provide your pipeline, so we can't tell you). > 1. How to free the memory allocated by > “gst_pad_alloc_buffer_and_set_caps()”? Why the error “free(): > invalid pointer: 0xb73c8008 ***” occurred. This seems a bit weird. Don't you get any other error before this ? If it was a double-free (or double unref), you would see a message stating that. What is most likely happening (I'm just guessing because I have no idea what your pipeline looks like or what your v4l2newcamsrc code looks like) is one of the following: * you are calling gst_buffer_unref on a buffer you already passed downstream * OR you are doing a free on the GST_BUFFER_DATA field of the buffer that downstream returned (you shouldn't do that, that memory location is handled by GstBuffer). You should figure out where that data you're trying to free was already freed by using valgrind. Edward > > > > Thanks. > Best Regards! > Hu Gang > > > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://p.sf.net/sfu/dev2dev-palm > _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Hu, Gang A
I seem to remember I posted patches for v4l2src to support
V4L2_MEMORY_USERPTR. You could look at these to see how to handle the situation. Check out https://bugzilla.gnome.org/show_bug.cgi?id=583890 In the pipeline you gave, the buffer will be allocated by the ffmpegcolorspace element, I believe. Look at the pad_alloc function of the ffmpegcolorspace sink pad to find out. (Default is to allocate using malloc().) Why do you want a USERPTR anyway? Regards, Arnout On Wednesday 04 August 2010 14:33:02, Hu, Gang A wrote: > Hi, > I had a v4l2 camera driver with the "V4L2_MEMORY_USERPTR" type memory > support and a camera source element "v4l2newcamsrc" to support this type > memory. When I running the pipeline bellow > "gst-launch v4l2newcamsrc num-buffers=1 ! ffmpegcolorspace ! > video/x-raw-yuv,width=640,height=480 ! filesink location=image_640.yuv" > The image can be captured successfully. > But when the buffers are freed in the camera source element, there will > always be an error message in the terminal. > > *** glibc detected *** /usr/local/meego/bin/gst-launch-0.10: free(): > invalid pointer: 0xb73c8008 *** ======= Backtrace: ========= > /lib/libc.so.6[0x550cc1] > /usr/local/meego/lib/libgstreamer-0.10.so.0(+0x29c06)[0xb7792c06] > /usr/local/meego/lib/libgstreamer-0.10.so.0(gst_mini_object_unref+0xaf)[0 > xb77b94df] . > > I use gst_pad_alloc_buffer_and_set_caps() to allocate the buffer from the > download element in the camera source element. When the application > exit, gst_buffer_unref (buffer) will be called to free the memory. This > code case the error above after debugging with GDB. > > I have two questions about that. > 1. Which element is responsible for the memory allocation when call > "gst_pad_alloc_buffer_and_set_caps()" in camera source element in my > pipeline. 2. How to free the memory allocated by > "gst_pad_alloc_buffer_and_set_caps()"? Why the error "free(): invalid > pointer: 0xb73c8008 ***" occurred. > > > > Thanks. > Best Regards! > Hu Gang -- Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286540 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 31BB CF53 8660 6F88 345D 54CC A836 5879 20D7 CF43 ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Hi,
I guess I found the reason after read my code and the patch for v4l2src. The error happened because the GST_BUFFER_DATA of the buffer from pad_alloc() are freed two times. When I allocated the buffer with gst_pad_alloc_buffer_and_set_caps(..., &buffer1). I assigned the GST_BUFFER_DATA to another GstBuffer "buffer2". GST_BUFFER_DATA (buffer2) =buffer1->data; Buffer2 is freed in some place and I guess the GST_BUFFER_DATA is freed also. So when buffer1 is unreffed, the double free error happened for buffer1->data. I use USERPTR to do the buffer sharing with the downstream element. BTW, Edward's guess is right. * OR you are doing a free on the GST_BUFFER_DATA field of the buffer that downstream returned (you shouldn't do that, that memory location is handled by GstBuffer). Thanks . Hu Gang. -----Original Message----- From: Arnout Vandecappelle [mailto:[hidden email]] Sent: Friday, August 06, 2010 12:35 AM To: [hidden email] Cc: Hu, Gang A Subject: Re: [gst-devel] Failed to free the memory allocated by gst_pad_alloc_buffer_and_set_caps() I seem to remember I posted patches for v4l2src to support V4L2_MEMORY_USERPTR. You could look at these to see how to handle the situation. Check out https://bugzilla.gnome.org/show_bug.cgi?id=583890 In the pipeline you gave, the buffer will be allocated by the ffmpegcolorspace element, I believe. Look at the pad_alloc function of the ffmpegcolorspace sink pad to find out. (Default is to allocate using malloc().) Why do you want a USERPTR anyway? Regards, Arnout On Wednesday 04 August 2010 14:33:02, Hu, Gang A wrote: > Hi, > I had a v4l2 camera driver with the "V4L2_MEMORY_USERPTR" type memory > support and a camera source element "v4l2newcamsrc" to support this type > memory. When I running the pipeline bellow > "gst-launch v4l2newcamsrc num-buffers=1 ! ffmpegcolorspace ! > video/x-raw-yuv,width=640,height=480 ! filesink location=image_640.yuv" > The image can be captured successfully. > But when the buffers are freed in the camera source element, there will > always be an error message in the terminal. > > *** glibc detected *** /usr/local/meego/bin/gst-launch-0.10: free(): > invalid pointer: 0xb73c8008 *** ======= Backtrace: ========= > /lib/libc.so.6[0x550cc1] > /usr/local/meego/lib/libgstreamer-0.10.so.0(+0x29c06)[0xb7792c06] > /usr/local/meego/lib/libgstreamer-0.10.so.0(gst_mini_object_unref+0xaf)[0 > xb77b94df] . > > I use gst_pad_alloc_buffer_and_set_caps() to allocate the buffer from the > download element in the camera source element. When the application > exit, gst_buffer_unref (buffer) will be called to free the memory. This > code case the error above after debugging with GDB. > > I have two questions about that. > 1. Which element is responsible for the memory allocation when call > "gst_pad_alloc_buffer_and_set_caps()" in camera source element in my > pipeline. 2. How to free the memory allocated by > "gst_pad_alloc_buffer_and_set_caps()"? Why the error "free(): invalid > pointer: 0xb73c8008 ***" occurred. > > > > Thanks. > Best Regards! > Hu Gang -- Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286540 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 31BB CF53 8660 6F88 345D 54CC A836 5879 20D7 CF43 ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |