<div dir="ltr"><div class="gmail-md"><h2 dir="auto">Summary of the bug:</h2>
<p dir="auto">Hello, dear developers:,</p>
<p dir="auto">I encountered a memory leak issue <a href="https://code.videolan.org/videolan/x264/-/issues/75">#75</a> while using FFmpeg with version git master. When I execute configure, if --enable-libx264 and --enable-gpl are enabled, it will trigger a problem. If I don't enable these two options, there won't be any problem. I tried compiling the latest master branch x264 on my own instead of downloading it from Ubuntu, and I was able to reproduce the issue.</p>
<p dir="auto">The FFmpeg team confirmed that this issue is related to a memory leak in the x264 library, not FFmpeg itself. As suggested by the FFmpeg developers, I am reporting this issue to the x264 team.</p>
<p dir="auto">Please confirm, I have also contacted the developers of FFmpeg, and here is their response:</p>
<h3 dir="auto">
<a href="#byjames10-days-ago" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-byjames10-days-ago"></a>by James, <a href="https://trac.ffmpeg.org/timeline?from=2024-12-20T12%3A55%3A06Z&precision=second" title="See timeline at Dec 20, 2024, 12:55:06 PM" rel="nofollow noreferrer noopener" target="_blank">10 days ago</a>
</h3>
<table dir="auto">
<tbody><tr>
<th align="right">Keywords:</th>
<td>bugs removed</td>
</tr>
<tr>
<th align="right">Priority:</th>
<td>
<p>important → <strong>normal</strong></p>
</td>
</tr>
<tr>
<th align="right">Resolution:</th>
<td>
<p>→ <strong>invalid</strong></p>
</td>
</tr>
<tr>
<th align="right">Status:</th>
<td>
<p>new → <strong>closed</strong></p>
</td>
</tr>
</tbody></table>
<p dir="auto">This looks like a memleak in libx264, not ffmpeg. x264_encoder_open() fails and apparently doesn't do a proper clean up. You should report it to them.</p>
<h2 dir="auto">
<a href="#how-to-reproduce" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-how-to-reproduce"></a>How to reproduce:</h2>
<p dir="auto">$unzip FFmpeg-master.zip<br>
$cd FFmpeg-master-dev<br>
$./configure --enable-libx264 --enable-gpl --cc=clang --cxx=clang++ --toolchain=clang-asan --enable-cross-compile</p>
<p dir="auto">$make -j 30<br>
$./ffmpeg -i poc test.mp4</p>
<p dir="auto"><a href="/-/project/536/uploads/34ddfa92d3eacbb3173ed8e9f89fe600/poc" class="gmail-gfm">poc</a></p>
<h2 dir="auto">
<a href="#crash-log" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-crash-log"></a>crash log:</h2>
<p dir="auto">=================================================================<br>
==1590113==ERROR: LeakSanitizer: detected memory leaks</p>
<p dir="auto">Direct leak of 136 byte(s) in 1 object(s) allocated from:</p>
<blockquote dir="auto">
<p>#0 0x5e7e1e17e67e in interceptor_malloc (/home/swift/workstation/github/FFmpeg-master/ffmpeg+0x98067e) (BuildId: <a href="https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b" title="Changeset 2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b" rel="nofollow noreferrer noopener" target="_blank">2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b</a>)<br>
<a href="https://trac.ffmpeg.org/ticket/1" title="#1: task: Test (closed: invalid)" rel="nofollow noreferrer noopener" target="_blank">#1</a> 0x731353c0c3d1 (/usr/lib/x86_64-linux-gnu/libx264.so.163+0xc3d1) (BuildId: <a href="https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=b2e7160a74448d05d96f3305d73fc2316edbedaf" title="Changeset b2e7160a74448d05d96f3305d73fc2316edbedaf" rel="nofollow noreferrer noopener" target="_blank">b2e7160a74448d05d96f3305d73fc2316edbedaf</a>)</p>
</blockquote>
<p dir="auto">Indirect leak of 30 byte(s) in 2 object(s) allocated from:</p>
<blockquote dir="auto">
<p>#0 0x5e7e1e169083 in interceptor_strdup (/home/swift/workstation/github/FFmpeg-master/ffmpeg+0x96b083) (BuildId: <a href="https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b" title="Changeset 2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b" rel="nofollow noreferrer noopener" target="_blank">2e3adc0cc0a1ce7cb06b6662338d6fd012a2a61b</a>)<br>
<a href="https://trac.ffmpeg.org/ticket/1" title="#1: task: Test (closed: invalid)" rel="nofollow noreferrer noopener" target="_blank">#1</a> 0x731353c0c353 (/usr/lib/x86_64-linux-gnu/libx264.so.163+0xc353) (BuildId: <a href="https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=b2e7160a74448d05d96f3305d73fc2316edbedaf" title="Changeset b2e7160a74448d05d96f3305d73fc2316edbedaf" rel="nofollow noreferrer noopener" target="_blank">b2e7160a74448d05d96f3305d73fc2316edbedaf</a>)</p>
</blockquote>
<p dir="auto">SUMMARY: AddressSanitizer: 166 byte(s) leaked in 3 allocation(s).</p>
<h2 dir="auto">
<a href="#ffmpeg-version" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-ffmpeg-version"></a>ffmpeg version</h2>
<p dir="auto">ffmpeg version 7.1.git Copyright (c) 2000-2024 the FFmpeg developers<br>
built with Ubuntu clang version 14.0.0-1ubuntu1.1<br>
configuration: --enable-libx264 --cc=clang --cxx=clang++ --enable-gpl --toolchain=clang-asan<br>
libavutil 59. 51.100 / 59. 51.100<br>
libavcodec 61. 27.101 / 61. 27.101<br>
libavformat 61. 9.101 / 61. 9.101<br>
libavdevice 61. 4.100 / 61. 4.100<br>
libavfilter 10. 6.101 / 10. 6.101<br>
libswscale 8. 12.100 / 8. 12.100<br>
libswresample 5. 4.100 / 5. 4.100<br>
libpostproc 58. 4.100 / 58. 4.100</p>
<h2 dir="auto">
<a href="#ubuntu-version" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-ubuntu-version"></a>ubuntu version</h2>
<p dir="auto">$ lsb_release -a<br>
No LSB modules are available.<br>
Distributor ID: Ubuntu<br>
Description: Ubuntu 22.04.3 LTS<br>
Release: 22.04<br>
Codename: jammy<br>
$ uname -r<br>
6.8.0-49-generic</p>
<h2 dir="auto">
<a href="#libx264-version" aria-hidden="true" class="gmail-anchor" id="gmail-user-content-libx264-version"></a>libx264 version</h2>
<p dir="auto">$ dpkg -s libx264-dev<br>
Package: libx264-dev<br>
Status: install ok installed<br>
Priority: optional<br>
Section: libdevel<br>
Installed-Size: 2761<br>
Maintainer: Ubuntu Developers <<a href="mailto:ubuntu-devel-discuss@lists.ubuntu.com">ubuntu-devel-discuss@lists.ubuntu.com</a>><br>
Architecture: amd64<br>
Multi-Arch: same<br>
Source: x264<br>
Version: 2:0.163.3060+git5db6aa6-2build1<br>
Depends: libx264-163 (= 2:0.163.3060+git5db6aa6-2build1)<br>
Description: development files for libx264</p>
<blockquote dir="auto">
<p>libx264 is an advanced encoding library for creating H.264 (MPEG-4 AVC)<br>
video streams.<br>
.<br>
This package contains the static library and headers used to build programs<br>
that use libx264.</p>
</blockquote>
<p dir="auto">Original-Maintainer: Debian Multimedia Maintainers <<a href="mailto:debian-multimedia@lists.debian.org">debian-multimedia@lists.debian.org</a>><br>
Homepage: <a href="https://www.videolan.org/developers/x264.html" rel="nofollow noreferrer noopener" target="_blank">https://www.videolan.org/developers/x264.html</a></p>
<p dir="auto">Thanks!</p></div></div>