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 779247 - Fix race in videotexturecache
Fix race in videotexturecache
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.11.1
Other Mac OS
: Normal normal
: 1.10.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-02-26 09:21 UTC by Nick Kallen
Modified: 2017-03-17 10:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Refactor duplicate code; ensure objects freed in right order (3.62 KB, patch)
2017-02-26 09:25 UTC, Nick Kallen
none Details | Review
Fixed very dumb bug (3.70 KB, patch)
2017-02-26 10:44 UTC, Nick Kallen
none Details | Review
g_malloc (3.71 KB, patch)
2017-03-04 09:38 UTC, Nick Kallen
committed Details | Review
Compiles on MacOS (1.19 KB, patch)
2017-03-04 11:13 UTC, Nick Kallen
none Details | Review
Compiles on MacOS (762 bytes, patch)
2017-03-04 11:15 UTC, Nick Kallen
committed Details | Review

Description Nick Kallen 2017-02-26 09:21:00 UTC
It is possible for the videotexturecache to be finalized before all of its textures. But when you then try to finalize a texture, the program will crash.

This happens during a race where avfvideosrc is stopped and there is a still a buffer that it produced somewhere in the pipeline.
Comment 1 Nick Kallen 2017-02-26 09:25:40 UTC
Created attachment 346740 [details] [review]
Refactor duplicate code; ensure objects freed in right order
Comment 2 Sebastian Dröge (slomo) 2017-02-26 10:22:29 UTC
Review of attachment 346740 [details] [review]:

::: sys/applemedia/videotexturecache.m
@@ +166,3 @@
           goto error;
 
+        textype = GST_VIDEO_GL_TEXTURE_TYPE_RGBA;

You're not setting the target here anymore, or are you elsewhere?

@@ +194,3 @@
 
+success: {
+  TextureWrapper *texture_data = malloc(sizeof(TextureWrapper));

g_new0(TextureWrapper, 1)
Comment 3 Nick Kallen 2017-02-26 10:44:57 UTC
Created attachment 346745 [details] [review]
Fixed very dumb bug
Comment 4 Sebastian Dröge (slomo) 2017-02-26 11:06:01 UTC
Review of attachment 346745 [details] [review]:

::: sys/applemedia/videotexturecache.m
@@ +194,3 @@
 
+success: {
+  TextureWrapper *texture_data = malloc(sizeof(TextureWrapper));

g_new0() here, or at least g_malloc()
Comment 5 Nick Kallen 2017-03-04 09:38:12 UTC
Created attachment 347194 [details] [review]
g_malloc
Comment 6 Sebastian Dröge (slomo) 2017-03-04 10:00:18 UTC
commit e557e93f3b4e922f9dd6fc5dcc04284522a693e8
Author: Nick Kallen <nickkallen@me.com>
Date:   Sun Feb 26 10:24:46 2017 +0100

    applemedia: ensure all textures are released before texturecache is released
    
    It was previously possible for videotexturecache to be finalized before all of
    its textures. Finalizing outstanding textures in this circumstance leads
    to a crash. This patch ensure resources are freed in the proper order.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779247
Comment 7 Sebastian Dröge (slomo) 2017-03-04 10:01:57 UTC
Review of attachment 347194 [details] [review]:

::: sys/applemedia/videotexturecache.m
@@ +140,3 @@
+    CFRelease(data->texture);
+    CFRelease(data->cache);
+    free(data);

Must be g_free() (changed before merging)

GLib allows to replace the malloc/free/calloc functions with something else, e.g. for debugging purposes. Not that anybody is ever going to do that on iOS...

@@ +194,3 @@
 
+success: {
+  TextureWrapper *texture_data = g_malloc(sizeof(TextureWrapper));

Changed to g_new(TextureWrapper, 1) which ensures that you don't accidentally allocate with the size of type A and assign that to a pointer to type B.
Comment 8 Nick Kallen 2017-03-04 11:09:26 UTC
OK THanks for making these changes on my behalf.... too much back and forth takes forever
Comment 9 Nick Kallen 2017-03-04 11:13:38 UTC
Created attachment 347198 [details] [review]
Compiles on MacOS
Comment 10 Nick Kallen 2017-03-04 11:15:55 UTC
Created attachment 347199 [details] [review]
Compiles on MacOS
Comment 11 Sebastian Dröge (slomo) 2017-03-04 15:35:48 UTC
commit 6e4354600d833deb1ac31a1303e80301658701d4
Author: Nick Kallen <nickkallen@me.com>
Date:   Sat Mar 4 12:12:52 2017 +0100

    applemedia: Fix video texture cache build issue on MacOS
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779247