Memory leak on OCR code #754

Open
opened 2026-01-29 16:52:52 +00:00 by claunia · 0 comments
Owner

Originally created by @cfsmp3 on GitHub (Mar 22, 2023).

According to address sanitizer. I tried to track this down for a bit but the logic we want (clearing data structures where we export the subtitles to file instead of close to where they are allocated... sigh) I didn't succeed today. Anyway, this is the output, which seems straight-forward until you start hunting it down :-)

The test file is here https://www.polyml.org/download/ (it's from another bug report):


Direct leak of 873472 byte(s) in 853 object(s) allocated from:
    #0 0x7f08ebcbf90f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x55caf596b9b0 in write_dvb_sub ../src/lib_ccx/dvb_subtitle_decoder.c:1615
    #2 0x55caf596d4d1 in dvbsub_handle_display_segment ../src/lib_ccx/dvb_subtitle_decoder.c:1768
    #3 0x55caf596ddca in dvbsub_decode ../src/lib_ccx/dvb_subtitle_decoder.c:1874
    #4 0x55caf59c2699 in process_data ../src/lib_ccx/general_loop.c:644
    #5 0x55caf59c567e in process_non_multiprogram_general_loop ../src/lib_ccx/general_loop.c:968
    #6 0x55caf59c629b in general_loop ../src/lib_ccx/general_loop.c:1062
    #7 0x55caf58c3986 in api_start ../src/ccextractor.c:205
    #8 0x55caf58c5cdb in main ../src/ccextractor.c:463
    #9 0x7f08eb02350f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Direct leak of 1436 byte(s) in 1436 object(s) allocated from:
    #0 0x7f08ebc73658 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
    #1 0x55caf593cb6d in ocr_bitmap ../src/lib_ccx/ocr.c:355
    #2 0x55caf59426c4 in ocr_rect ../src/lib_ccx/ocr.c:963
    #3 0x55caf596c35d in write_dvb_sub ../src/lib_ccx/dvb_subtitle_decoder.c:1675
    #4 0x55caf596d4d1 in dvbsub_handle_display_segment ../src/lib_ccx/dvb_subtitle_decoder.c:1768
    #5 0x55caf596ddca in dvbsub_decode ../src/lib_ccx/dvb_subtitle_decoder.c:1874
    #6 0x55caf59c2699 in process_data ../src/lib_ccx/general_loop.c:644
    #7 0x55caf59c567e in process_non_multiprogram_general_loop ../src/lib_ccx/general_loop.c:968
    #8 0x55caf59c629b in general_loop ../src/lib_ccx/general_loop.c:1062
    #9 0x55caf58c3986 in api_start ../src/ccextractor.c:205
    #10 0x55caf58c5cdb in main ../src/ccextractor.c:463
    #11 0x7f08eb02350f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 874908 byte(s) leaked in 2289 allocation(s).
Originally created by @cfsmp3 on GitHub (Mar 22, 2023). According to address sanitizer. I tried to track this down for a bit but the logic we want (clearing data structures where we export the subtitles to file instead of close to where they are allocated... sigh) I didn't succeed today. Anyway, this is the output, which seems straight-forward until you start hunting it down :-) The test file is here https://www.polyml.org/download/ (it's from another bug report): ``` Direct leak of 873472 byte(s) in 853 object(s) allocated from: #0 0x7f08ebcbf90f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x55caf596b9b0 in write_dvb_sub ../src/lib_ccx/dvb_subtitle_decoder.c:1615 #2 0x55caf596d4d1 in dvbsub_handle_display_segment ../src/lib_ccx/dvb_subtitle_decoder.c:1768 #3 0x55caf596ddca in dvbsub_decode ../src/lib_ccx/dvb_subtitle_decoder.c:1874 #4 0x55caf59c2699 in process_data ../src/lib_ccx/general_loop.c:644 #5 0x55caf59c567e in process_non_multiprogram_general_loop ../src/lib_ccx/general_loop.c:968 #6 0x55caf59c629b in general_loop ../src/lib_ccx/general_loop.c:1062 #7 0x55caf58c3986 in api_start ../src/ccextractor.c:205 #8 0x55caf58c5cdb in main ../src/ccextractor.c:463 #9 0x7f08eb02350f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Direct leak of 1436 byte(s) in 1436 object(s) allocated from: #0 0x7f08ebc73658 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439 #1 0x55caf593cb6d in ocr_bitmap ../src/lib_ccx/ocr.c:355 #2 0x55caf59426c4 in ocr_rect ../src/lib_ccx/ocr.c:963 #3 0x55caf596c35d in write_dvb_sub ../src/lib_ccx/dvb_subtitle_decoder.c:1675 #4 0x55caf596d4d1 in dvbsub_handle_display_segment ../src/lib_ccx/dvb_subtitle_decoder.c:1768 #5 0x55caf596ddca in dvbsub_decode ../src/lib_ccx/dvb_subtitle_decoder.c:1874 #6 0x55caf59c2699 in process_data ../src/lib_ccx/general_loop.c:644 #7 0x55caf59c567e in process_non_multiprogram_general_loop ../src/lib_ccx/general_loop.c:968 #8 0x55caf59c629b in general_loop ../src/lib_ccx/general_loop.c:1062 #9 0x55caf58c3986 in api_start ../src/ccextractor.c:205 #10 0x55caf58c5cdb in main ../src/ccextractor.c:463 #11 0x7f08eb02350f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 SUMMARY: AddressSanitizer: 874908 byte(s) leaked in 2289 allocation(s). ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#754