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 672640 - [patch] memory leaks
[patch] memory leaks
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2012-03-22 18:28 UTC by Pavel Vasin
Modified: 2012-05-02 18:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (1.50 KB, patch)
2012-03-22 18:31 UTC, Pavel Vasin
accepted-commit_now Details | Review
patch2 (2.47 KB, patch)
2012-03-23 12:54 UTC, Pavel Vasin
needs-work Details | Review
patch3 (1.44 KB, patch)
2012-03-23 12:55 UTC, Pavel Vasin
needs-work Details | Review
patch4 (1.23 KB, patch)
2012-03-23 12:55 UTC, Pavel Vasin
needs-work Details | Review
patch5 (1.27 KB, patch)
2012-03-23 12:56 UTC, Pavel Vasin
needs-work Details | Review
patch6 (1.87 KB, patch)
2012-03-23 12:56 UTC, Pavel Vasin
needs-work Details | Review
patch2 (1.02 KB, patch)
2012-03-23 16:17 UTC, Pavel Vasin
committed Details | Review
patch5 (726 bytes, patch)
2012-03-23 16:22 UTC, Pavel Vasin
accepted-commit_now Details | Review
patch6 (1.07 KB, patch)
2012-03-23 16:34 UTC, Pavel Vasin
committed Details | Review

Description Pavel Vasin 2012-03-22 18:28:06 UTC
Hi, this is my first attempt to contribute to gnome, please don't bite :-)

from valgrind log:
==31043== 7 bytes in 1 blocks are definitely lost in loss record 213 of 6,861
==31043==    at 0x402B018: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==31043==    by 0x417789A: ??? (in /usr/lib/libglib-2.0.so.0.3122.0)
==31043==    by 0x4177C42: g_malloc (in /usr/lib/libglib-2.0.so.0.3122.0)
==31043==    by 0x418DC3A: g_strdup (in /usr/lib/libglib-2.0.so.0.3122.0)
==31043==    by 0x408C470: meta_display_open (display.c:475)
==31043==    by 0x40A4D42: meta_run (main.c:552)
==31043==    by 0x8048A74: main (mutter.c:96)

1. hostname seems never freed
2. if gethostname() fails hostname will be uninitialized

patch attached
Comment 1 Pavel Vasin 2012-03-22 18:31:47 UTC
Created attachment 210370 [details] [review]
proposed patch
Comment 2 Pavel Vasin 2012-03-23 12:54:30 UTC
Created attachment 210417 [details] [review]
patch2

And a few more fixes for memory leaks...
Comment 3 Pavel Vasin 2012-03-23 12:55:06 UTC
Created attachment 210419 [details] [review]
patch3
Comment 4 Pavel Vasin 2012-03-23 12:55:41 UTC
Created attachment 210420 [details] [review]
patch4
Comment 5 Pavel Vasin 2012-03-23 12:56:18 UTC
Created attachment 210422 [details] [review]
patch5
Comment 6 Pavel Vasin 2012-03-23 12:56:49 UTC
Created attachment 210423 [details] [review]
patch6
Comment 7 Rui Matos 2012-03-23 15:28:39 UTC
Review of attachment 210417 [details] [review]:

Ups, yes thanks for finding this. This needs a freeze break and I think it's worth of it since this function is called often. Pavel, will you request the freeze break or do you want me to do it for you? Also, do you have commit access to git.gnome.org?
Comment 8 Pavel Vasin 2012-03-23 15:45:48 UTC
Rui Matos, this is my first contribute to gnome, so I have no access to git and I don't know requires it freeze break or not or something... Please take care about this patches :-)
Comment 9 Owen Taylor 2012-03-23 15:46:37 UTC
Review of attachment 210417 [details] [review]:

Thanks for the patch - I do think we need a freeze break for this. However, the patch needs some cosmetic improvement - in particular, it needs an informative subject ike "meta_stack_list_window(): Fix leaked GList"

I don't think including the valgrind log adds any information for someone looking at this commit in a week or a two years - it would be much more useful in the bug report than in the commit message
Comment 10 Owen Taylor 2012-03-23 15:49:23 UTC
Review of attachment 210420 [details] [review]:

Not correct - I don't really care if we clean up properly at shutdown time - it's a lot of work for zero gain for the user, but if we do try to clean up, we can't just g_free() some block of memory allocated by another piece of code , which could have pointers in it, etc.
Comment 11 Owen Taylor 2012-03-23 15:54:28 UTC
Review of attachment 210422 [details] [review]:

Needs Subject/Body imrovements, but otherwise looks good
Comment 12 Owen Taylor 2012-03-23 15:59:05 UTC
Review of attachment 210423 [details] [review]:

Good catch! needs Subject/Body improvements, but we should include this one in the freeze break request as well. Would also be good to get this into Metacity
Comment 13 Pavel Vasin 2012-03-23 16:17:04 UTC
Created attachment 210442 [details] [review]
patch2
Comment 14 Pavel Vasin 2012-03-23 16:22:12 UTC
Created attachment 210443 [details] [review]
patch5
Comment 15 Pavel Vasin 2012-03-23 16:34:19 UTC
Created attachment 210444 [details] [review]
patch6

Would you like to I open bug against metacity for this patch?
Comment 16 Owen Taylor 2012-03-23 16:46:54 UTC
(In reply to comment #15)
> Created an attachment (id=210444) [details] [review]
> patch6 [details]
> 
> Would you like to I open bug against metacity for this patch?

Don't think that's necessary - we can just land the patch in Metacity as well - my guess is that it will apply close to unmodified.
Comment 17 Pavel Vasin 2012-03-23 17:00:42 UTC
Comment on attachment 210420 [details] [review]
patch4

Oh... it really requires non-trivial changes
Comment 18 Rui Matos 2012-03-23 17:09:30 UTC
Review of attachment 210419 [details] [review]:

::: src/core/screen.c
@@ +1024,3 @@
+  while (screen->workspaces)
+    meta_workspace_remove(screen->workspaces->data);
+

This doesn't work because of the assertion in meta_workspace_remove().

Also, freeing MetaScreens isn't something we do unless the process is exiting AFAIK, so it's not terribly important.
Comment 19 Rui Matos 2012-03-23 17:11:20 UTC
Review of attachment 210442 [details] [review]:

Looks good now, thanks. I've requested a freeze break for this one.
Comment 20 Rui Matos 2012-03-23 17:14:07 UTC
Review of attachment 210444 [details] [review]:

Nit in the summary: it's not a GList but a GSList. We can just amend it when before pushing. Looks good otherwise.
Comment 21 Pavel Vasin 2012-03-24 05:55:03 UTC
(In reply to comment #18)
> This doesn't work because of the assertion in meta_workspace_remove().

What if move freeing memory from meta_workspace_remove to finalizer and on closing MetaScreen just unref MetaWorkspaces, how do you think?
Comment 22 André Klapper 2012-03-24 08:41:08 UTC
The two patches with "accepted-commit_now" status have received approvals from the release-team - please commit these two.
Comment 23 Rui Matos 2012-03-24 18:33:40 UTC
The approved patches have been commited now. Thanks Pavel!
Comment 24 Rui Matos 2012-03-24 20:27:56 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > Created an attachment (id=210444) [details] [review] [details] [review]
> > patch6 [details] [details]
> > 
> > Would you like to I open bug against metacity for this patch?
> 
> Don't think that's necessary - we can just land the patch in Metacity as well -
> my guess is that it will apply close to unmodified.

I pushed this one into metacity.
Comment 25 Jasper St. Pierre (not reading bugmail) 2012-04-24 15:39:24 UTC
Review of attachment 210443 [details] [review]:

I'm not sure this is a memory leak (the stack tracker never gets freed unless the screen gets freed, which means you're shutting down mutter). It is a correction to meta_stack_tracker_free, though.
Comment 26 Jasper St. Pierre (not reading bugmail) 2012-04-24 15:40:11 UTC
Review of attachment 210370 [details] [review]:

Sure as well.