Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Memory leak with flatpak upgrade #5816

Closed
4 tasks done
hfiguiere opened this issue May 18, 2024 · 2 comments · Fixed by #5823
Closed
4 tasks done

[Bug]: Memory leak with flatpak upgrade #5816

hfiguiere opened this issue May 18, 2024 · 2 comments · Fixed by #5823
Assignees
Labels
bug cli Issues involving the flatpak command

Comments

@hfiguiere
Copy link
Collaborator

hfiguiere commented May 18, 2024

Checklist

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.
  • If this is an issue with a particular app, I have tried filing it in the appropriate issue tracker for the app (e.g. under https://github.com/flathub/) and determined that it is an issue with Flatpak itself.
  • This issue is not a report of a security vulnerability (see here if you need to report a security issue).

Flatpak version

master

What Linux distribution are you using?

Fedora Silverblue

Linux distribution version

39

What architecture are you using?

x86_64

How to reproduce

Run flatpak upgrade (flatpak is built locally with ASan)

==2159501==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f308c2cdcc7 in calloc (/lib64/libasan.so.8+0xd8cc7) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599)
    #1 0x7f308c10d2e1 in g_malloc0 (/lib64/libglib-2.0.so.0+0x622e1) (BuildId: b6cf99186f67796c572114f06c6ee38c300c212b)
    #2 0x7f308beb454e in g_type_create_instance (/lib64/libgobject-2.0.so.0+0x3f54e) (BuildId: 0378350ec67b6c4cb51aad5c4d581cce802a077b)
    #3 0x7f308be99fb3 in g_object_new_internal.part.0 (/lib64/libgobject-2.0.so.0+0x24fb3) (BuildId: 0378350ec67b6c4cb51aad5c4d581cce802a077b)
    #4 0x7f308be9c1a2 in g_object_new_valist (/lib64/libgobject-2.0.so.0+0x271a2) (BuildId: 0378350ec67b6c4cb51aad5c4d581cce802a077b)
    #5 0x7f308be9c55e in g_object_new (/lib64/libgobject-2.0.so.0+0x2755e) (BuildId: 0378350ec67b6c4cb51aad5c4d581cce802a077b)
    #6 0x5b437e in flatpak_dir_new_full ../common/flatpak-dir.c:13817
    #7 0x5b4683 in flatpak_dir_get_system_default ../common/flatpak-dir.c:13854
    #8 0x4e7186 in flatpak_option_context_parse ../app/flatpak-main.c:426
    #9 0x4d15b8 in flatpak_builtin_update ../app/flatpak-builtins-update.c:93
    #10 0x4ea095 in flatpak_run ../app/flatpak-main.c:857
    #11 0x4eaad6 in main ../app/flatpak-main.c:962
    #12 0x7f308b55e149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 7ea8d85df0e89b90c63ac7ed2b3578b2e7728756)
    #13 0x7f308b55e20a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 7ea8d85df0e89b90c63ac7ed2b3578b2e7728756)
    #14 0x41a9d4 in _start (/var/home/hub/source/flatpak/_build/app/flatpak+0x41a9d4) (BuildId: 57dbba9435d28cdf371716ce433197d8f39d665b)

Then there is a long list of indirect leaks.

Expected Behavior

No memory leak

Actual Behavior

ASan show memory leaks.

Additional Information

I have looked quickly and can't find how it leaks. The dir gets directly added to a g_ptr_array() and this should be alright disposing of it.

@hfiguiere
Copy link
Collaborator Author

Note: it doesn't happen with plain flatpak install.

Also I believe it might be related to the code path going through EOL runtimes.

@hfiguiere
Copy link
Collaborator Author

Valgrind also show it

==1611800== 71,948 (128 direct, 71,820 indirect) bytes in 1 blocks are definitely lost in loss record 2,734 of 2,734
==1611800==    at 0x4849E60: calloc (vg_replace_malloc.c:1595)
==1611800==    by 0x48D72E1: g_malloc0 (gmem.c:163)
==1611800==    by 0x4BD654E: g_type_create_instance (gtype.c:1979)
==1611800==    by 0x4BBBFB3: g_object_new_internal.part.0 (gobject.c:2245)
==1611800==    by 0x4BBE1A2: UnknownInlinedFun (gobject.c:2562)
==1611800==    by 0x4BBE1A2: g_object_new_valist (gobject.c:2584)
==1611800==    by 0x4BBE55E: g_object_new (gobject.c:2057)
==1611800==    by 0x1D1F78: flatpak_dir_new_full.lto_priv.0 (flatpak-dir.c:13814)
==1611800==    by 0x1D201E: flatpak_dir_get_system_default (flatpak-dir.c:13851)
==1611800==    by 0x1A4FE9: flatpak_option_context_parse (flatpak-main.c:426)
==1611800==    by 0x19BC1B: flatpak_builtin_update (flatpak-builtins-update.c:93)
==1611800==    by 0x159818: UnknownInlinedFun (flatpak-main.c:857)
==1611800==    by 0x159818: main (flatpak-main.c:962)

Note the amount of "indirect"

@hfiguiere hfiguiere added bug cli Issues involving the flatpak command and removed needs triage labels May 22, 2024
hfiguiere added a commit to hfiguiere/flatpak that referenced this issue May 24, 2024
Close flatpak#5816

Also reenable leak checking in the test

Signed-off-by: Hubert Figuière <[email protected]>
hfiguiere added a commit to hfiguiere/flatpak that referenced this issue May 24, 2024
Close flatpak#5816

Also reenable some leak checking in CI

Signed-off-by: Hubert Figuière <[email protected]>
hfiguiere added a commit to hfiguiere/flatpak that referenced this issue May 24, 2024
hfiguiere added a commit to hfiguiere/flatpak that referenced this issue May 24, 2024
@hfiguiere hfiguiere changed the title [Bug]: Memory leak with flaptak upgrade [Bug]: Memory leak with flatpak upgrade May 24, 2024
@hfiguiere hfiguiere self-assigned this May 24, 2024
TingPing pushed a commit that referenced this issue May 24, 2024
Close #5816

Signed-off-by: Hubert Figuière <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cli Issues involving the flatpak command
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant