Opened 6 years ago

Closed 4 years ago

#7394 closed defect (fixed)

Small memory leak if slice threading initialization fails

Reported by: Carl Eugen Hoyos Owned by:
Priority: minor Component: avcodec
Version: git-master Keywords: leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

There is still a memory leak after ticket #6593 was handled.

$ valgrind --leak-check=full ./ffmpeg_g -f rawvideo -s hd1080 -i /dev/zero -thread_type slice -threads 32 -c:v dnxhd -b:v 36M -qmax 1 -f null -
==10443== Memcheck, a memory error detector
==10443== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==10443== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==10443== Command: ./ffmpeg_g -f rawvideo -s hd1080 -i /dev/zero -thread_type slice -threads 32 -c:v dnxhd -b:v 36M -qmax 1 -f null -
==10443==
ffmpeg version N-91790-g23fe072 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.4.0 (GCC)
  configuration: --enable-gpl --enable-gnutls --enable-libxml2
  libavutil      56. 19.100 / 56. 19.100
  libavcodec     58. 27.101 / 58. 27.101
  libavformat    58. 17.106 / 58. 17.106
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, rawvideo, from '/dev/zero':
  Duration: N/A, start: 0.000000, bitrate: 622080 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> dnxhd (native))
Press [q] to stop, [?] for help
[dnxhd @ 0x8f23b80] Application has requested 32 threads. Using a thread count greater than 16 is not recommended.
[dnxhd @ 0x8f23b80] qmax must be at least 2
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
==10443==
==10443== HEAP SUMMARY:
==10443==     in use at exit: 13,033 bytes in 44 blocks
==10443==   total heap usage: 3,889 allocs, 3,845 frees, 8,932,037 bytes allocated
==10443==
==10443== 88 bytes in 1 blocks are definitely lost in loss record 9 of 14
==10443==    at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10443==    by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10443==    by 0x10F741F: av_mallocz (mem.c:87)
==10443==    by 0xA44DF8: ff_slice_thread_init (pthread_slice.c:157)
==10443==    by 0xB222F8: avcodec_open2 (utils.c:738)
==10443==    by 0x49A8E5: init_output_stream.constprop.23 (ffmpeg.c:3513)
==10443==    by 0x49F6A5: reap_filters (ffmpeg.c:1446)
==10443==    by 0x4A3E07: transcode (ffmpeg.c:4637)
==10443==    by 0x4820F2: main (ffmpeg.c:4888)
==10443==
==10443== 8,432 bytes in 31 blocks are possibly lost in loss record 14 of 14
==10443==    at 0x4C292B8: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10443==    by 0x4010E69: allocate_dtv (in /lib64/ld-2.15.so)
==10443==    by 0x401157D: _dl_allocate_tls (in /lib64/ld-2.15.so)
==10443==    by 0x5F44619: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.15.so)
==10443==    by 0x11112A7: avpriv_slicethread_create (slicethread.c:147)
==10443==    by 0xA44E30: ff_slice_thread_init (pthread_slice.c:159)
==10443==    by 0xB222F8: avcodec_open2 (utils.c:738)
==10443==    by 0x49A8E5: init_output_stream.constprop.23 (ffmpeg.c:3513)
==10443==    by 0x49F6A5: reap_filters (ffmpeg.c:1446)
==10443==    by 0x4A3E07: transcode (ffmpeg.c:4637)
==10443==    by 0x4820F2: main (ffmpeg.c:4888)
==10443==
==10443== LEAK SUMMARY:
==10443==    definitely lost: 88 bytes in 1 blocks
==10443==    indirectly lost: 0 bytes in 0 blocks
==10443==      possibly lost: 8,432 bytes in 31 blocks
==10443==    still reachable: 4,513 bytes in 12 blocks
==10443==         suppressed: 0 bytes in 0 blocks
==10443== Reachable blocks (those to which a pointer was found) are not shown.
==10443== To see them, rerun with: --leak-check=full --show-reachable=yes
==10443==
==10443== For counts of detected and suppressed errors, rerun with: -v
==10443== ERROR SUMMARY: 8 errors from 4 contexts (suppressed: 2 from 2)

Change History (1)

comment:1 by Carl Eugen Hoyos, 4 years ago

Resolution: fixed
Status: newclosed

This leak has been fixed.

Note: See TracTickets for help on using tickets.