Your message dated Sat, 21 Nov 2026 11:04:57 +0000
with message-id <[email protected]>
and subject line Bug#1153907: fixed in libgd2 2.3.3-14~deb13u3
has caused the Debian Bug report #1153907,
regarding src:libgd2: gdImageAvif memory leak in loop (missing upstream PR #832)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1153907: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1153907
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: src:libgd2
Version: 2.3.3-14
Severity: normal
Tags: upstream patch
Forwarded: https://github.com/libgd/libgd/pull/832

Dear Maintainer,

Repeated calls to gdImageAvifCtx() (or imageavif() via PHP bindings) in a loop
result in a continuous, linear leak of native C heap memory (~1.6 MB per call).

Over a batch run of 500-1,000 images, memory accumulates into multiple gigabytes
until the process is killed by the Linux OOM killer. Calling malloc_trim(0) does
not reclaim this memory.

=== Root Cause ===
In src/gd_avif.c, gdImageAvifCtx allocates an avifImage struct:
    avifIm = avifImageCreate(gdImageSX(im), gdImageSY(im), 8, subsampling);

In the cleanup block of _gdImageAvifCtx(), avifImageDestroy(avifIm) is missing.

This was reported upstream in libgd/libgd#831 and fixed in upstream PR #832:
    https://github.com/libgd/libgd/pull/832
Commit: Fix #831: gdImageAvif memory leak

PHP also backported this into its bundled copy in commit 036bed01ce:
    https://github.com/php/php-src/commit/036bed01ce

However, upstream LibGD has not tagged any new release since 2.3.3 (2021).
Because Debian libgd2 (2.3.3-14) is built from the 2.3.3 source tarball,
Debian's libgd.so.3 is missing this fix.

Inspecting the dynamic symbol table of Debian's 
/usr/lib/x86_64-linux-gnu/libgd.so.3
confirms that avifImageCreate is imported, but avifImageDestroy is absent:
    $ objdump -T /usr/lib/x86_64-linux-gnu/libgd.so.3 | grep -i avifImage
    0000000000000000      DF *UND*  0000000000000000  Base        
avifImageYUVToRGB
    0000000000000000      DF *UND*  0000000000000000  Base        
avifImageCreate
    0000000000000000      DF *UND*  0000000000000000  Base        
avifImageRGBToYUV

=== Minimal Reproducer (PHP CLI) ===
<?php
for ($i = 1; $i <= 50; $i++) {
    $img = imagecreatetruecolor(800, 800);
    $tmp = "/tmp/test_{$i}.avif";
    imageavif($img, $tmp, 80);
    imagedestroy($img);
    @unlink($tmp);
}

During this loop, process Resident Set Size (VmRSS via /proc/self/status) grows
by ~80 MB (~1.6 MB/image) while Zend emalloc stays flat at 2 MB.
By comparison, imagewebp() and imagejpeg() have 0 bytes leaked under identical
conditions.

=== Proposed Fix ===
Please cherry-pick upstream PR #832 into debian/patches for src:libgd2:
    https://github.com/libgd/libgd/pull/832
This adds `if (avifIm) avifImageDestroy(avifIm);` to the cleanup block in
src/gd_avif.c.

References:
- Upstream LibGD Issue: https://github.com/libgd/libgd/issues/831
- Upstream LibGD PR: https://github.com/libgd/libgd/pull/832
- PHP Core Issue: https://github.com/php/php-src/issues/25442

--- End Message ---
--- Begin Message ---
Source: libgd2
Source-Version: 2.3.3-14~deb13u3
Done: Ondřej Surý <[email protected]>

We believe that the bug you reported is fixed in the latest version of
libgd2, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Ondřej Surý <[email protected]> (supplier of updated libgd2 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Wed, 18 Nov 2026 10:46:43 +0100
Source: libgd2
Architecture: source
Version: 2.3.3-14~deb13u3
Distribution: trixie-security
Urgency: high
Maintainer: GD Team <[email protected]>
Changed-By: Ondřej Surý <[email protected]>
Closes: 1153907
Changes:
 libgd2 (2.3.3-14~deb13u3) trixie-security; urgency=high
 .
   * Add upstream patch to fix memory leaks in AVIF reading and writing
     (Closes: #1153907)
Checksums-Sha1:
 1f6f025c7727b431722ffb60c3540cf0aeb94c2f 2472 libgd2_2.3.3-14~deb13u3.dsc
 a275344fb56161df6a06679bf0bf29c30930d8eb 3593182 libgd2_2.3.3.orig.tar.gz
 67af4156a213d0f54d9b88207c44ba1e62652d20 37872 
libgd2_2.3.3-14~deb13u3.debian.tar.xz
 f20c1f258531bad96c753bae798c838606c01956 9626 
libgd2_2.3.3-14~deb13u3_amd64.buildinfo
Checksums-Sha256:
 53cfa4f318f3504f08bef04cff47d074aefc573aaa864609b5e9a9df996700a1 2472 
libgd2_2.3.3-14~deb13u3.dsc
 dd3f1f0bb016edcc0b2d082e8229c822ad1d02223511997c80461481759b1ed2 3593182 
libgd2_2.3.3.orig.tar.gz
 4ca7eead5644159149e0230f069a41019747d84f861fbfd9dffe76f881fb9cb9 37872 
libgd2_2.3.3-14~deb13u3.debian.tar.xz
 5ac042811e50fa24e8e2c66735f77a1d23e7a41cfd65be1a11289d83af211a6b 9626 
libgd2_2.3.3-14~deb13u3_amd64.buildinfo
Files:
 4fc2a2da93e19f29dc6041306acd17ed 2472 graphics optional 
libgd2_2.3.3-14~deb13u3.dsc
 bf6d41ecb3148a6238a3058eb3d6224a 3593182 graphics optional 
libgd2_2.3.3.orig.tar.gz
 41e0f1c4b5d67d66d8cfa6f7cedb64ea 37872 graphics optional 
libgd2_2.3.3-14~deb13u3.debian.tar.xz
 78c881412e9af0651662120b045b5d16 9626 graphics optional 
libgd2_2.3.3-14~deb13u3_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEw2Gx4wKVQ+vGJel9g3Kkd++uWcIFAmr9dppfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEMz
NjFCMUUzMDI5NTQzRUJDNjI1RTk3RDgzNzJBNDc3RUZBRTU5QzIACgkQg3Kkd++u
WcIfVRAAqSIdAxxrJi22YnsxIqcufKtNy9JeYtI8pX6djOX0Rf/0E8M2vhKUOnw0
8aRoMaBBhzNBTb2q4mc6aFJGFb7wc4v+PIy3UKa5NgliMCsmCXJv84MYES0XKYAM
Ujnw6G0qPEL5JQ74pSTX7UL2q2UvvHeZfqxgpOO3Ewg/rDfooO09ErBpbgoouZxu
XVwjNj3g3yFNAiMSYeTMYPq3PEG5XUjsrSl7E0U0VvZU4cgBN6r+ByNFS+5TCS+c
Y31qkguLS4s+GKuhP5XA7XToo7yIhz3ZeODS5Txf78Vk9XrdDdCW3rpnuJ/46dtM
/q1S0zQK28usbzCdF6HTPsp3Jk2wQtWGWnXc5fNTJH0zHqxaRgU2hp5bejkJCRkQ
L1s07nJRAsosd3uFgSOMpfh3ciSbEYiMRm2eTwyJPzLBjgIreJXDIL8ItPq0c0jW
GQGv+PWpl9qIKaUKNUa4GAcJhiz3JDKfBuxgMNKjOmoT5mJym18gJ8s0majjU2Sl
pKvyYZTQdv6MVzn7iYR0sxD6jzyfpCDp7DSyfprq/cdkW6tT4bmilV+TvBp+GEA8
uaxCZu6IONRSzyu/TpLjZOs6//8oe/KtqZ+IDWSGrWfwqakr6GM2Mdur/N7eOSG7
tf/BwQ+O86E8DU9UbR5EjtOIpL79Q2S/W5lngazhzzEZ47WqNBg=
=R3Zp
-----END PGP SIGNATURE-----

Attachment: pgpYWhJ2ZlDCg.pgp
Description: PGP signature


--- End Message ---

Reply via email to