Bug 573536 - [GTK3] Potential native memory leak in Tree.calculateWidth()
Summary: [GTK3] Potential native memory leak in Tree.calculateWidth()
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-14 05:18 EDT by Simeon Andreev CLA
Modified: 2021-05-27 07:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2021-05-14 05:18:03 EDT
When running valgrind with Eclipse 4.20 (simple operations, debug a Java snippet and switch perspectives), one of the reported leaks is:

==45117== 2,040 (1,632 direct, 408 indirect) bytes in 102 blocks are definitely lost in loss record 1,070 of 38,924
==45117==    at 0x4C2B017: malloc (vg_replace_malloc.c:380)
==45117==    by 0x2E3BD68D: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.1)
==45117==    by 0x2E3D4C8D: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5600.1)
==45117==    by 0x3478396D: gtk_tree_path_new (gtktreemodel.c:594)
==45117==    by 0x3479433C: gtk_tree_store_get_path (gtktreestore.c:600)
==45117==    by 0x3CC9D581: Java_org_eclipse_swt_internal_gtk_GTK_gtk_1tree_1model_1get_1path (in /home/sandreev/eclipses/eclipse4_20SDK_m20210407/configuration/org.eclipse.osgi/222/0/.cp/libswt-pi3-gtk-4944r15.so)

I've checked all callers of GTK.gtk_tree_model_get_path(), the only code which maybe sometimes doesn't free the output is found in Tree.calculateWidth(). In particular, there is a return statement before the call that should be freeing the resulting path. Unfortunately I've been unable to create a snippet that showcases the memory leak, so I can't be 100% certain.
Comment 1 Eclipse Genie CLA 2021-05-14 05:30:40 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/180602
Comment 2 Simeon Andreev CLA 2021-05-17 05:58:20 EDT
The early return was added in 2009: https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=093c579a4ffd9551acb901bba9617e7aa776989d

I've set 3.8 as affected, though I'm sure earlier versions are also affected. 3.8 should be "low enough" though, at least for me/Andrey.
Comment 3 Simeon Andreev CLA 2021-05-17 11:01:14 EDT
Assuming the leak in gtk_tree_model_get_path() is covered by bug 573573. I was unable to create an SWT snippet where the early return branch of Tree.calculateWidth() is executed.