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 780171 - Memory leak in object_instance_resolve()
Memory leak in object_instance_resolve()
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
1.47.x
Other Linux
: Normal major
: ---
Assigned To: Philip Chimento
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2017-03-16 22:46 UTC by Philip Chimento
Modified: 2017-03-19 05:35 UTC
See Also:
GNOME target: 3.24
GNOME version: ---


Attachments
object: Fix memory leak in resolve (1.57 KB, patch)
2017-03-16 22:47 UTC, Philip Chimento
none Details | Review
object: Fix memory leak in resolve (2.15 KB, patch)
2017-03-16 23:38 UTC, Philip Chimento
none Details | Review
valgrind output (124.21 KB, application/x-xz)
2017-03-17 00:20 UTC, luke.nukem.jones@gmail.com
  Details
object: Fix memory leak in resolve (2.23 KB, patch)
2017-03-17 18:34 UTC, Philip Chimento
committed Details | Review

Description Philip Chimento 2017-03-16 22:46:24 UTC
Valgrind log from bug 642652: https://paste.gnome.org/pem1d4cvn
Comment 1 Philip Chimento 2017-03-16 22:47:07 UTC
Created attachment 348135 [details] [review]
object: Fix memory leak in resolve

The "name" string, allocated in gjs_get_string_id(), wasn't getting freed
at every exit point of the function. (It will be nice to clean this up in
1.49.x with our autoptr classes...)

After a certain point in the function it's not needed, so we just free
the string there.
Comment 2 Florian Müllner 2017-03-16 22:59:09 UTC
Review of attachment 348135 [details] [review]:

Looks like it misses another early return, otherwise LGTM

::: gi/object.cpp
@@ +792,3 @@
             *resolved = true;
             g_base_info_unref((GIBaseInfo *)vfunc);
+            g_free(name);

There's another exit path right above this block - that'll need another free(), no?
Comment 3 Philip Chimento 2017-03-16 23:38:03 UTC
Created attachment 348136 [details] [review]
object: Fix memory leak in resolve

The "name" string, allocated in gjs_get_string_id(), wasn't getting freed
at every exit point of the function. (It will be nice to clean this up in
1.49.x with our autoptr classes...)

After a certain point in the function it's not needed, so we just free
the string there.
Comment 4 Philip Chimento 2017-03-16 23:39:00 UTC
I changed it to g_free(name) inside that block before either of those exit points are reached.
Comment 5 luke.nukem.jones@gmail.com 2017-03-17 00:20:48 UTC
Created attachment 348138 [details]
valgrind output

run with;

valgrind --log-file="valgrind-shell" --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=definite,possible --leak-resolution=med --num-callers=40 gnome-shell -r
Comment 6 Hussam Al-Tayeb 2017-03-17 15:55:30 UTC
For some time now I've been seeing a 150MB an hour leak (which wasn't in gnome 3.22) when the screen is locked but not dimmed/off because I am usually running some application that inhibits 'screensavers'. With this patch, that particular leak is down to ~25MB an hour. This is a major step :)

The leak in bug 778368 is still there.
Nevertheless this is a massive improvement.
Thank you very much for caring to spend time and improve the situation.
Comment 7 Cosimo Cecchi 2017-03-17 16:14:09 UTC
Review of attachment 348136 [details] [review]:

Looks good to me. Probably worth asking for a freeze break exception for this?
Comment 8 Philip Chimento 2017-03-17 18:24:00 UTC
This is embarrassing, but I discovered a case where it would crash, while running under code coverage...
Comment 9 Philip Chimento 2017-03-17 18:34:21 UTC
Created attachment 348203 [details] [review]
object: Fix memory leak in resolve

The "name" string, allocated in gjs_get_string_id(), wasn't getting freed
at every exit point of the function. (It will be nice to clean this up in
1.49.x with our autoptr classes...)

After a certain point in the function it's not needed, so we just free
the string there.
Comment 10 Cosimo Cecchi 2017-03-17 18:37:21 UTC
Review of attachment 348203 [details] [review]:

ACK
Comment 11 Philip Chimento 2017-03-19 05:35:00 UTC
Attachment 348203 [details] pushed as 9050118 - object: Fix memory leak in resolve