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

Fluid: potential memory leaks #552

Closed
Albrecht-S opened this issue Nov 23, 2022 · 2 comments
Closed

Fluid: potential memory leaks #552

Albrecht-S opened this issue Nov 23, 2022 · 2 comments
Labels
fluid Fast Light User Interface Designer (fluid) Prio 2 - Low documentation error or undocumented side-effect

Comments

@Albrecht-S
Copy link
Member

I'm aware that memory leaks reported by tools like valgrind and/or address sanitizer (ASAN) may be false positives and can often be ignored. I removed all common and well-known reports from fontconfig etc. anyway.

The remaining reports seem to be related to the new DesignViewer and Fl_Preferences.

@MatthiasWM Please check if these reports are relevant and feel free to close this issue if not. Thanks.

Tested on Linux with current git (410e57d). Run fluid about_panel.fl and close the main window immediately after it opens. No other actions required. In my tests the code view was not opened at all. I used about_panel.fl because it's small but I saw similar reports with other fluid files as well.

Part 1: valgrind

$ valgrind --leak-check=full bin/fluid ../../fluid/about_panel.fl

28 bytes in 1 blocks are definitely lost in loss record 381 of 1,593
   at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x514D38E: strdup (strdup.c:42)
   by 0x2E4F77: Fl_Posix_System_Driver::strdup(char const*) (Fl_Posix_System_Driver.H:84)
   by 0x2B05D3: fl_strdup (fl_string_functions.cxx:33)
   by 0x262857: Fl_Preferences::get(char const*, char*&, char const*) (Fl_Preferences.cxx:795)
   by 0x2181AA: shell_prefs_get() (shell_command.cxx:55)
   by 0x20B82F: make_main_window() (fluid.cxx:1504)
   by 0x20CF33: main (fluid.cxx:1963)

28 bytes in 1 blocks are definitely lost in loss record 382 of 1,593
   at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x514D38E: strdup (strdup.c:42)
   by 0x2E4F77: Fl_Posix_System_Driver::strdup(char const*) (Fl_Posix_System_Driver.H:84)
   by 0x2B05D3: fl_strdup (fl_string_functions.cxx:33)
   by 0x218323: shell_settings_read() (shell_command.cxx:92)
   by 0x207CEE: read_file(char const*, int, Strategy) (file.cxx:665)
   by 0x20D050: main (fluid.cxx:1983)

1,160 (136 direct, 1,024 indirect) bytes in 1 blocks are definitely lost in loss record 1,419 of 1,593
   at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1C796B: DesignViewer::DesignViewer(int, int, int, int, char const*) (CodeEditor.cxx:308)
   by 0x215B71: make_sourceview() (function_panel.cxx:1548)
   by 0x20B4F9: toggle_sourceview_cb(Fl_Double_Window*, void*) (fluid.cxx:1460)
   by 0x20CFE8: main (fluid.cxx:1976)

1,160 (136 direct, 1,024 indirect) bytes in 1 blocks are definitely lost in loss record 1,420 of 1,593
   at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1C796B: DesignViewer::DesignViewer(int, int, int, int, char const*) (CodeEditor.cxx:308)
   by 0x215D3D: make_sourceview() (function_panel.cxx:1569)
   by 0x20B4F9: toggle_sourceview_cb(Fl_Double_Window*, void*) (fluid.cxx:1460)
   by 0x20CFE8: main (fluid.cxx:1976)

Part 2: LeakSanitizer (ASAN)

Direct leak of 136 byte(s) in 1 object(s) allocated from:
    #0 0x7fc800357587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x55ead197b942 in DesignViewer::DesignViewer(int, int, int, int, char const*) ../../fluid/CodeEditor.cxx:308
    #2 0x55ead1a13777 in make_sourceview() ../../fluid/function_panel.cxx:1569
    #3 0x55ead1a05fcd in toggle_sourceview_cb(Fl_Double_Window*, void*) ../../fluid/fluid.cxx:1460
    #4 0x55ead1a09419 in main ../../fluid/fluid.cxx:1976
    #5 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 136 byte(s) in 1 object(s) allocated from:
    #0 0x7fc800357587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x55ead197b942 in DesignViewer::DesignViewer(int, int, int, int, char const*) ../../fluid/CodeEditor.cxx:308
    #2 0x55ead1a13569 in make_sourceview() ../../fluid/function_panel.cxx:1548
    #3 0x55ead1a05fcd in toggle_sourceview_cb(Fl_Double_Window*, void*) ../../fluid/fluid.cxx:1460
    #4 0x55ead1a09419 in main ../../fluid/fluid.cxx:1976
    #5 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0x7fc8002de3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
    #1 0x55ead1b5d3c9 in Fl_Posix_System_Driver::strdup(char const*) ../../src/drivers/Unix/../Posix/Fl_Posix_System_Driver.H:84
    #2 0x55ead1b45cd0 in fl_strdup ../../src/fl_string_functions.cxx:33
    #3 0x55ead1aa3239 in Fl_Preferences::get(char const*, char*&, char const*) ../../src/Fl_Preferences.cxx:795
    #4 0x55ead1a16d18 in shell_prefs_get() ../../fluid/shell_command.cxx:55
    #5 0x55ead1a06697 in make_main_window() ../../fluid/fluid.cxx:1504
    #6 0x55ead1a09358 in main ../../fluid/fluid.cxx:1963
    #7 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0x7fc8002de3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
    #1 0x55ead1b5d3c9 in Fl_Posix_System_Driver::strdup(char const*) ../../src/drivers/Unix/../Posix/Fl_Posix_System_Driver.H:84
    #2 0x55ead1b45cd0 in fl_strdup ../../src/fl_string_functions.cxx:33
    #3 0x55ead1a16eb2 in shell_settings_read() ../../fluid/shell_command.cxx:92
    #4 0x55ead19ff404 in read_file(char const*, int, Strategy) ../../fluid/file.cxx:665
    #5 0x55ead1a094ae in main ../../fluid/fluid.cxx:1983
    #6 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 1024 byte(s) in 1 object(s) allocated from:
    #0 0x7fc800355808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x55ead1ad8374 in Fl_Text_Buffer::Fl_Text_Buffer(int, int) ../../src/Fl_Text_Buffer.cxx:108
    #2 0x55ead197b958 in DesignViewer::DesignViewer(int, int, int, int, char const*) ../../fluid/CodeEditor.cxx:308
    #3 0x55ead1a13569 in make_sourceview() ../../fluid/function_panel.cxx:1548
    #4 0x55ead1a05fcd in toggle_sourceview_cb(Fl_Double_Window*, void*) ../../fluid/fluid.cxx:1460
    #5 0x55ead1a09419 in main ../../fluid/fluid.cxx:1976
    #6 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 1024 byte(s) in 1 object(s) allocated from:
    #0 0x7fc800355808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x55ead1ad8374 in Fl_Text_Buffer::Fl_Text_Buffer(int, int) ../../src/Fl_Text_Buffer.cxx:108
    #2 0x55ead197b958 in DesignViewer::DesignViewer(int, int, int, int, char const*) ../../fluid/CodeEditor.cxx:308
    #3 0x55ead1a13777 in make_sourceview() ../../fluid/function_panel.cxx:1569
    #4 0x55ead1a05fcd in toggle_sourceview_cb(Fl_Double_Window*, void*) ../../fluid/fluid.cxx:1460
    #5 0x55ead1a09419 in main ../../fluid/fluid.cxx:1976
    #6 0x7fc7ff827082 in __libc_start_main ../csu/libc-start.c:308

Note: Leak Sanitizer (ASAN) can be used with g++ and/or clang++. If you need help to set up ASAN support I can give some hints. Note that you can't run programs instrumented with ASAN by using valgrind (it's not compatible).

@Albrecht-S Albrecht-S added fluid Fast Light User Interface Designer (fluid) Prio 2 - Low documentation error or undocumented side-effect labels Nov 23, 2022
@MatthiasWM
Copy link
Contributor

Valgrind message 1 and 2 are not an issue because allocation are not accumulating while FLUID is running. The same is true for 3 and 4, but I fixed those nevertheless because there was a naming issue.

The ASAN leaks point to the same issues.

817a97b should fix 3 and 4, and even 1 and 2 (but no similar cases)

@Albrecht-S
Copy link
Member Author

Thanks for fixing "3 and 4" and for clarification.

FTR: the remaining "non-leaks" found by ASAN are reported:

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0x7f501287c3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
    #1 0x5620f95745fd in Fl_Posix_System_Driver::strdup(char const*) ../../src/drivers/Unix/../Posix/Fl_Posix_System_Driver.H:84
    #2 0x5620f955cf04 in fl_strdup ../../src/fl_string_functions.cxx:33
    #3 0x5620f94ba455 in Fl_Preferences::get(char const*, char*&, char const*) ../../src/Fl_Preferences.cxx:795
    #4 0x5620f942ddc2 in shell_prefs_get() ../../fluid/shell_command.cxx:55
    #5 0x5620f941d703 in make_main_window() ../../fluid/fluid.cxx:1504
    #6 0x5620f94203c4 in main ../../fluid/fluid.cxx:1963
    #7 0x7f5011dc5082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0x7f501287c3ed in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cc:445
    #1 0x5620f95745fd in Fl_Posix_System_Driver::strdup(char const*) ../../src/drivers/Unix/../Posix/Fl_Posix_System_Driver.H:84
    #2 0x5620f955cf04 in fl_strdup ../../src/fl_string_functions.cxx:33
    #3 0x5620f942df5c in shell_settings_read() ../../fluid/shell_command.cxx:92
    #4 0x5620f9416470 in read_file(char const*, int, Strategy) ../../fluid/file.cxx:665
    #5 0x5620f942051a in main ../../fluid/fluid.cxx:1983
    #6 0x7f5011dc5082 in __libc_start_main ../csu/libc-start.c:308

Thanks. Closing the issue as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fluid Fast Light User Interface Designer (fluid) Prio 2 - Low documentation error or undocumented side-effect
Projects
None yet
Development

No branches or pull requests

2 participants