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 585551 - AppSrc bindings do not handle buffer ownership correctly
AppSrc bindings do not handle buffer ownership correctly
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-sharp
git master
Other Windows
: Normal normal
: 0.9.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-06-12 12:43 UTC by Maarten Bosmans
Modified: 2009-09-11 08:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase for AppSrc.PushBuffer (3.05 KB, application/octet-stream)
2009-06-12 12:47 UTC, Maarten Bosmans
  Details
Fix for generator (1.52 KB, patch)
2009-06-12 14:41 UTC, Maarten Bosmans
committed Details | Review
Now some custom code can go away... (3.48 KB, patch)
2009-06-13 07:50 UTC, Maarten Bosmans
committed Details | Review
Now even more custom code can go away... (7.58 KB, patch)
2009-06-13 09:29 UTC, Maarten Bosmans
committed Details | Review

Description Maarten Bosmans 2009-06-12 12:43:08 UTC
There are two problems:
  - An error about an assertion about the refcount of a miniobject.
  - An System.AccessViolationException thrown for the buffer data.

The first one occurs when using AppSrc.PushBuffer(buffer).

The second results from using new Gst.Buffer(byte[] data); to construct the buffer to push to the appsrc.
Comment 1 Maarten Bosmans 2009-06-12 12:47:29 UTC
Created attachment 136416 [details]
Testcase for AppSrc.PushBuffer

This program exposes the bug. It should just show a moving line on a yellow background until the video window is closed.

Both for constructing the buffer and pushing it to the appsrc there are two ways of doing it. The one that uses the preferred api does not work, see comments in the file.
Comment 2 Sebastian Dröge (slomo) 2009-06-12 13:22:52 UTC
commit b3b018c916fbdc5009839ba1c04f85b55ab62973
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Fri Jun 12 15:21:28 2009 +0200

    AppSrc.PushBuffer() takes ownership of the buffer
    
    Part of bug #585551.


Now it works for me (as attached), well, it doesn't crash anymore :) But it uses more and more memory... I'll investigate.
Comment 3 Maarten Bosmans 2009-06-12 14:41:03 UTC
Created attachment 136438 [details] [review]
Fix for generator

Why not fix the generator instead?
Comment 4 Sebastian Dröge (slomo) 2009-06-12 20:16:39 UTC
(In reply to comment #3)
> Created an attachment (id=136438) [edit]
> Fix for generator
> 
> Why not fix the generator instead?

To have a fast solution available to continue debugging :) Thanks for that patch, I've adapted it to also have the same for GObject. Now some custom code can go away
Comment 5 Maarten Bosmans 2009-06-13 07:50:52 UTC
Created attachment 136489 [details] [review]
Now some custom code can go away...
Comment 6 Sebastian Dröge (slomo) 2009-06-13 08:03:24 UTC
Actually some more custom code can go away: Gst.Pad.Push(), Gst.Bus.Post(), Gst.Bin.Add(), ...  These are not using .OwnedHandle but instead call gst_mini_object_ref() on the Handle by hand.

I'll commit your patch tomorrow and any other patch you've attached until then to remove the other custom code, otherwise I'll remove the custom code then ;)
Comment 7 Maarten Bosmans 2009-06-13 09:29:49 UTC
Created attachment 136492 [details] [review]
Now even more custom code can go away... 

I only touched custom code which used gst_mini_object_ref.

The other places like gst_mini_object_copy and Bin.Add are left as an excercise for the committer ;-)
Comment 8 Sebastian Dröge (slomo) 2009-06-14 18:04:52 UTC
Thanks, it's all committed now :)
Comment 9 Sebastian Dröge (slomo) 2009-06-17 11:39:50 UTC
The buffer creation works too now:

commit 1c1fe228b4d9d9b669bed91526e25f5b80bc6347
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Wed Jun 17 13:36:53 2009 +0200

    Don't forget to set the freefunc of buffers
    
    Partially fixes bug #585551.



Is there anything left for this bug except the increasing memory usage?
Comment 10 Maarten Bosmans 2009-06-18 10:12:07 UTC
Yes! with this patch all the issues are fixed.

Also the failure of PadTest.TestPushUnlinked I reported in #585541 is gone now, so we have a regression test in place and don't need the attached testcase anymore.
Comment 11 Sebastian Dröge (slomo) 2009-06-20 09:44:48 UTC
Great :) But does your attached test case use more and more memory over time for you too? I have no idea what exactly is leaking here, the native buffers (and their data) are all freed.

Also, if you want to prepare a patch we can add that test case as an example application :)