Leak when marshaling caller-allocated GValues from Python implemented vfuncs
Submitted by Simon Feltman
Link to original bug (#736502)
Description
make check.valgrind TEST_NAMES=test_gi.TestPythonGObject.test_vfunc_return_ref_count
==12923== 24 bytes in 1 blocks are definitely lost in loss record 376 of 5,117 ==12923== at 0x4C2745D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==12923== by 0x132C8DE6: g_malloc (gmem.c:97) ==12923== by 0x132E1A22: g_slice_alloc (gslice.c:1007) ==12923== by 0x132E1A62: g_slice_alloc0 (gslice.c:1032) ==12923== by 0x123F64BC: pygi_arg_gvalue_from_py_marshal (pygi-struct-marshal.c:119) ==12923== by 0x123F67BF: pygi_arg_struct_from_py_marshal (pygi-struct-marshal.c:241) ==12923== by 0x123F6BAF: arg_struct_from_py_marshal_adapter (pygi-struct-marshal.c:329) ==12923== by 0x123E7B6A: _pygi_closure_set_out_arguments (pygi-closure.c:508) ==12923== by 0x123E7E30: _pygi_closure_handle (pygi-closure.c:592) ==12923== by 0x135D3B7A: ffi_closure_unix64_inner (in /usr/lib64/libffi.so.6.0.1) ==12923== by 0x135D3EF3: ffi_closure_unix64 (in /usr/lib64/libffi.so.6.0.1) ==12923== by 0x13E0170F: gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (gimarshallingtests.c:4334) ==12923== by 0x135D3D8B: ffi_call_unix64 (in /usr/lib64/libffi.so.6.0.1) ==12923== by 0x135D36BB: ffi_call (in /usr/lib64/libffi.so.6.0.1) ==12923== by 0x123EB5B3: pygi_invoke_c_callable (pygi-invoke.c:628) ==12923== by 0x123EC893: _function_cache_invoke_real (pygi-cache.c:714) ==12923== by 0x123ECA92: pygi_function_cache_invoke (pygi-cache.c:793) ==12923== by 0x123EB6B5: pygi_callable_info_invoke (pygi-invoke.c:671) ==12923== by 0x123EB7F9: _wrap_g_callable_info_invoke (pygi-invoke.c:708) ==12923== by 0x123D8715: _callable_info_call (pygi-info.c:557)
I believe the problem is we don't take into account caller allocated memory for the GValue which may be held in arg->v_pointer:
https://git.gnome.org/browse/pygobject/tree/gi/pygi-struct-marshal.c?id=3.13.91#n118