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 751601 - Incorrect wrapping of virtual functions returning objects with transfer full
Incorrect wrapping of virtual functions returning objects with transfer full
Status: RESOLVED OBSOLETE
Product: gstreamermm
Classification: Bindings
Component: general
git master
Other Linux
: Normal critical
: ---
Assigned To: gstreamermm-maint
gstreamermm-maint
Depends on: 751606
Blocks:
 
 
Reported: 2015-06-27 21:06 UTC by Michał Wróbel
Modified: 2021-07-05 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH 1/...] tests/Makefile.am clean-ups (8.61 KB, patch)
2015-06-27 21:22 UTC, Michał Wróbel
none Details | Review
[PATCH 2/...] clean-ups in tests/*/*.h (6.81 KB, patch)
2015-06-27 21:24 UTC, Michał Wróbel
none Details | Review
[PATCH 3/...] improve and re-enable RegisterPluginTest tests (3.15 KB, patch)
2015-06-27 21:24 UTC, Michał Wróbel
none Details | Review
[PATCH 4/...] Gst::BaseTransform: fix refs of {fixate,transform}_caps() return values (9.40 KB, patch)
2015-06-27 21:25 UTC, Michał Wróbel
none Details | Review
[PATCH 5/...] Gst::BaseSrc: fix refs of {get_caps,fixate}() return values (13.62 KB, patch)
2015-06-27 21:57 UTC, Michał Wróbel
none Details | Review
[PATCH 5/...] Gst::BaseSrc: fix refs of {get_caps,fixate}() return values (13.82 KB, patch)
2015-06-27 22:52 UTC, Michał Wróbel
none Details | Review
[PATCH 6/...] Gst::BaseSink: set_caps(), event(): use return_value attribute (7.18 KB, patch)
2015-06-27 22:55 UTC, Michał Wróbel
none Details | Review
[PATCH 7/...] Gst::BaseSink: fix refs of {get_caps,fixate}() return values (12.31 KB, patch)
2015-06-27 23:06 UTC, Michał Wróbel
none Details | Review
[PATCH 8/...] Gst::Allocator: fix ref of alloc() return value (4.07 KB, patch)
2015-06-27 23:28 UTC, Michał Wróbel
none Details | Review
[PATCH 9/...] Gst::AudioBaseSrc: fix refs of create_ringbuffer() return values (13.05 KB, patch)
2015-06-28 12:52 UTC, Michał Wróbel
none Details | Review
[PATCH 10/...] Gst::AudioBaseSink: fix refs of create_ringbuffer() return values (10.85 KB, patch)
2015-06-28 12:53 UTC, Michał Wróbel
none Details | Review

Description Michał Wróbel 2015-06-27 21:06:22 UTC
The list of affected functions can be obtained by grepping for "_WRAP_VFUNC(Glib::RefPtr" and checking the documentation or the source code whether the functions is supposed to return by transfer full or transfer none.

The *_vfunc_callback virtual functions generated from _WRAP_VFUNC on functions returning RefPtrs without the attribute refreturn_ctype use unwrap() on the RefPtr returned from C++ virtual methods. As soon as the temporary RefPtr is destroyed (which is immediately after completing current statement) the unwrapped C-style pointer returned from the virtual function becomes invalid as the reference that should be associated with it (due to transfer full) is not there anymore. For objects which have refcount = 1 this will cause destroying the object and will almost immediately lead to assert failures in GObject checks, double frees and/or segfaults - depending on the way the pointer is used. For objects with greater refcount, the errors will be deferred or in some cases may not appear at all.


The mentioned mm attribute 'refreturn_ctype' replaces unwrap() with unwrap_copy() in the generated code. unwrap_copy() increments the refcount for the returned C-style pointer to GObject and thus fixes the problem.

Along with the fixes I will provide unit tests in the patches. The patches will come in series for increased readability.
Comment 1 Michał Wróbel 2015-06-27 21:22:30 UTC
Created attachment 306222 [details] [review]
[PATCH 1/...] tests/Makefile.am clean-ups
Comment 2 Michał Wróbel 2015-06-27 21:24:14 UTC
Created attachment 306223 [details] [review]
[PATCH 2/...] clean-ups in tests/*/*.h
Comment 3 Michał Wróbel 2015-06-27 21:24:39 UTC
Created attachment 306224 [details] [review]
[PATCH 3/...] improve and re-enable RegisterPluginTest tests
Comment 4 Michał Wróbel 2015-06-27 21:25:24 UTC
Created attachment 306225 [details] [review]
[PATCH 4/...] Gst::BaseTransform: fix refs of {fixate,transform}_caps() return values
Comment 5 Michał Wróbel 2015-06-27 21:57:56 UTC
Created attachment 306226 [details] [review]
[PATCH 5/...] Gst::BaseSrc: fix refs of {get_caps,fixate}() return values
Comment 6 Michał Wróbel 2015-06-27 22:52:50 UTC
Created attachment 306227 [details] [review]
[PATCH 5/...] Gst::BaseSrc: fix refs of {get_caps,fixate}() return values
Comment 7 Michał Wróbel 2015-06-27 22:55:14 UTC
Created attachment 306228 [details] [review]
[PATCH 6/...] Gst::BaseSink: set_caps(), event(): use return_value attribute
Comment 8 Michał Wróbel 2015-06-27 23:06:27 UTC
Created attachment 306229 [details] [review]
[PATCH 7/...] Gst::BaseSink: fix refs of {get_caps,fixate}() return values
Comment 9 Michał Wróbel 2015-06-27 23:28:28 UTC
Created attachment 306230 [details] [review]
[PATCH 8/...] Gst::Allocator: fix ref of alloc() return value
Comment 10 Michał Wróbel 2015-06-28 12:52:17 UTC
Created attachment 306236 [details] [review]
[PATCH 9/...] Gst::AudioBaseSrc: fix refs of create_ringbuffer() return values
Comment 11 Michał Wróbel 2015-06-28 12:53:22 UTC
Created attachment 306237 [details] [review]
[PATCH 10/...] Gst::AudioBaseSink: fix refs of create_ringbuffer()  return values
Comment 12 Marcin Kolny (IRC: loganek) 2015-06-29 09:27:06 UTC
Thanks for your work. I improved a little commit messages, and applied your patches to master branch except two most recent patches. They could be applied for gstreamermm 1.5.x, and after GStreamer's bug will be resolved.
Comment 13 Michał Wróbel 2015-07-22 13:29:05 UTC
The mentioned GStreamer's bug that blocks this one is https://bugzilla.gnome.org/show_bug.cgi?id=751606
Comment 14 GNOME Infrastructure Team 2021-07-05 12:28:12 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/gstreamermm/-/issues/

Thank you for your understanding and your help.