umlaeute/v4l2loopback — Issue #10: memory leak in yuv4mpeg_to_v4l2.c
Author: arpu
Created: 2011-12-15 16:43:13+00:00
State: open

hello

after run yuv4mpeg_to_v4l2.c example i get high mem usage here is the valgrind output

the problem is p=NULL; i think we should malloc this bytes?

valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes bin/yuv4mpeg_to_v4l2_debug /dev/video3 < /tmp/s3
==5143== Memcheck, a memory error detector
==5143== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==5143== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==5143== Command: bin/yuv4mpeg_to_v4l2_debug /dev/video3
==5143==
==5143== Syscall param ioctl(generic) points to uninitialised byte(s)
==5143== at 0x4F0B197: ioctl (syscall-template.S:82)
==5143== by 0x400DDA: open_video (yuv4mpeg_to_v4l2.c:156)
==5143== by 0x400E84: main (yuv4mpeg_to_v4l2.c:169)
==5143== Address 0x7ff000184 is on thread 1's stack
==5143== Uninitialised value was created by a stack allocation
==5143== at 0x400D64: open_video (yuv4mpeg_to_v4l2.c:150)
==5143==
^C==5143==
==5143== HEAP SUMMARY:
==5143== in use at exit: 259,224 bytes in 318 blocks
==5143== total heap usage: 318 allocs, 0 frees, 259,224 bytes allocated
==5143==
==5143== 120 bytes in 1 blocks are definitely lost in loss record 1 of 3
==5143== at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==5143== by 0x4E96148: getdelim (iogetdelim.c:68)
==5143== by 0x400B5E: read_header (yuv4mpeg_to_v4l2.c:101)
==5143== by 0x400C58: process_header (yuv4mpeg_to_v4l2.c:123)
==5143== by 0x400E7F: main (yuv4mpeg_to_v4l2.c:168)
==5143==
==5143== 37,920 bytes in 316 blocks are definitely lost in loss record 2 of 3
==5143== at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==5143== by 0x4E96148: getdelim (iogetdelim.c:68)
==5143== by 0x400B5E: read_header (yuv4mpeg_to_v4l2.c:101)
==5143== by 0x400D55: copy_frames (yuv4mpeg_to_v4l2.c:135)
==5143== by 0x400E89: main (yuv4mpeg_to_v4l2.c:170)
==5143==
==5143== 221,184 bytes in 1 blocks are still reachable in loss record 3 of 3
==5143== at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==5143== by 0x400CBA: copy_frames (yuv4mpeg_to_v4l2.c:133)
==5143== by 0x400E89: main (yuv4mpeg_to_v4l2.c:170)
==5143==
==5143== LEAK SUMMARY:
==5143== definitely lost: 38,040 bytes in 317 blocks
==5143== indirectly lost: 0 bytes in 0 blocks
==5143== possibly lost: 0 bytes in 0 blocks
==5143== still reachable: 221,184 bytes in 1 blocks
==5143== suppressed: 0 bytes in 0 blocks
==5143==
==5143== For counts of detected and suppressed errors, rerun with: -v
==5143== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 4 from 4)