gstreamer-java / gst1-java-core

Java bindings for GStreamer 1.x
GNU Lesser General Public License v3.0
188 stars 72 forks source link

Invalidate structure after ownership transferred to promise in Promise.reply #178

Closed kezhuw closed 4 years ago

kezhuw commented 4 years ago
If we don't invalidate after Promise.reply, we may sit in situations:

1. structure got freed while it is owned by promise, we can get hit from
   gst log:

   ```
   (PromiseTest:13221): GStreamer-CRITICAL **: 10:28:01.594: gst_structure_free: assertion 'GST_STRUCTURE_REFCOUNT (structure) == NULL' failed
   ```
2. structure got freed after its owning promise freed, we got
   double-free.

3. structure got used after freed due to interrupted before reply or
   owning promise freed.
neilcsmith-net commented 4 years ago

Thanks! But not sure this is the right fix. Have you tried changing the underlying mapping in GstPromiseAPI to

void gst_promise_reply(Promise promise, @Invalidate Structure s);
kezhuw commented 4 years ago

@neilcsmith-net You are right, after dove into https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/master/gst/gstpromise.c#L162, I think @Invalidate is the right fix, since there are chances the reply got swallow due to interrupted.