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

Fix memory leak when VNC exit #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ndsl7109256
Copy link
Collaborator

  • Register client cleanup function when during initialization to ensure that twin_peer_t is freed properly when the client disconnects.
  • Properly release resources during VNC server shutdown by unreferencin current_fb and free the framebuffer allocated for tx->framebuffer

Close #76

- Register client cleanup function when during initialization to ensure
that twin_peer_t is freed properly when the client disconnects.
- Properly release resources during VNC server shutdown by unreferencin
current_fb and free the framebuffer allocated for tx->framebuffer

Close sysprog21#76
@ndsl7109256 ndsl7109256 requested review from jserv and jouae and removed request for jouae December 18, 2024 08:08
@ndsl7109256
Copy link
Collaborator Author

@huaxinliao Could you help me verify if there is another memory leak in Raspberry Pi?

@huaxinliao
Copy link
Collaborator

huaxinliao commented Dec 20, 2024

Through my experiments, I found the following errors on the Raspberry Pi and Ubuntu 24.04. These are the same as the ones mentioned in #76.

=================================================================
==4364==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0xe3cc1eae76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xc73625ffc908 in twin_path_create src/path.c:584
    #2 0xc73625feafa4 in apps_flower_start apps/multi.c:256
    #3 0xc73625feafa4 in apps_multi_start apps/multi.c:288
    #4 0xc73625fe66d8 in main apps/main.c:109
    #5 0xe3cc1e6784c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #6 0xe3cc1e678594 in __libc_start_main_impl ../csu/libc-start.c:360
    #7 0xc73625fe71ac in _start (/home/huaxin/ndsl7109256/mado/demo-sdl+0x71ac) (BuildId: d18e212ac3a9665fa3151ef34ee47f98add57b6f)

Indirect leak of 32768 byte(s) in 1 object(s) allocated from:
    #0 0xe3cc1eae646c in realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:85
    #1 0xc73625ff9ff4 in _twin_path_sdraw src/path.c:105
    #2 0xc73625ffad68 in twin_path_draw src/path.c:134
    #3 0xc73625ffad68 in twin_path_draw_polar src/path.c:142
    #4 0xc73625ffad68 in twin_path_arc src/path.c:231
    #5 0xc73625ffb73c in twin_path_arc_ellipse src/path.c:368
    #6 0xc73625feb19c in draw_flower apps/multi.c:241
    #7 0xc73625feb19c in apps_flower_start apps/multi.c:268
    #8 0xc73625feb19c in apps_multi_start apps/multi.c:288
    #9 0xc73625fe66d8 in main apps/main.c:109
    #10 0xe3cc1e6784c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #11 0xe3cc1e678594 in __libc_start_main_impl ../csu/libc-start.c:360
    #12 0xc73625fe71ac in _start (/home/huaxin/ndsl7109256/mado/demo-sdl+0x71ac) (BuildId: d18e212ac3a9665fa3151ef34ee47f98add57b6f)

SUMMARY: AddressSanitizer: 32840 byte(s) leaked in 2 allocation(s).

Below are the improvements I propose in apps/multi.c to address the aforementioned errors.

static void apps_flower_start(twin_screen_t *screen, int x, int y, int w, int h)
     draw_flower(path, D(3), 5);
     twin_paint_path(pixmap, 0xffe2d2d2, path);
     twin_path_destroy(stroke);
+    twin_path_destroy(path);
     twin_window_show(window);
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak found in VNC backend
2 participants