Memory leak with GError
There's a memory leak in testEverythingBasic.js
with Regress.test_owned_gerror_callback()
that can be found with valgrind:
==32397== 44 (16 direct, 28 indirect) bytes in 1 blocks are definitely lost in loss record 935 of 1,536
==32397== at 0x4C2BBE0: malloc (vg_replace_malloc.c:299)
==32397== by 0x5AC9485: g_malloc (gmem.c:94)
==32397== by 0x5AE10DB: g_slice_alloc (gslice.c:1025)
==32397== by 0x5AAF4E8: g_error_new_literal (gerror.c:471)
==32397== by 0x1CD0C658: regress_test_owned_gerror_callback (regress.c:3867)
==32397== by 0x5071D3F: ffi_call_unix64 (in /usr/lib/x86_64-linux-gnu/libffi.so.6.0.2)
==32397== by 0x50717A7: ffi_call (in /usr/lib/x86_64-linux-gnu/libffi.so.6.0.2)
==32397== by 0x6C61688: ??? (function.cpp:1037)
==32397== by 0x6C6333F: ??? (function.cpp:1357)
==32397== by 0x6581A8D: js::CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) (jscntxtinlines.h:239)
==32397== by 0x6573DEE: js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) (Interpreter.cpp:447)
==32397== by 0x6567FF2: CallFromStack (Interpreter.cpp:510)
==32397== by 0x6567FF2: Interpret(JSContext*, js::RunState&) (Interpreter.cpp:2922)
This may well be the same thing as #35 (closed) where we need to special-case freeing GError
. On the other hand, since we have a custom JSClass
for GError
, it may be something wrong with that class's finalizer in gi/gerror.cpp
.