Package: valgrind Version: 1:3.19.0-1 Severity: normal Dear Maintainer,
Consider the following snippet, reduced from eperl HEAD:
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static void putenvf(const char *fmt, ...) {
char *cp;
va_list ap;
va_start(ap, fmt);
vasprintf(&cp, fmt, ap);
va_end(ap);
putenv(cp);
}
int main() {
putenvf("SCRIPT_SRC_PATH=%s", "/gaming");
putenvf("SCRIPT_SRC_PATH_FILE=%s", "gaming");
putenvf("SCRIPT_SRC_PATH_DIR=%s", "/");
putenvf("SCRIPT_SRC_URL=%s", "file:///gaming");
putenvf("SCRIPT_SRC_URL_FILE=%s", "gaming");
putenvf("SCRIPT_SRC_URL_DIR=%.*s", "file://");
putenvf("SCRIPT_SRC_SIZE=%zu", (size_t)12345);
putenvf("SCRIPT_SRC_OWNER=%s", "root");
putenvf("VERSION_INTERPRETER=ePerl/%s", "EPERL_VERSION_SHORT");
putenvf("VERSION_LANGUAGE=Perl/%s", "AC_perl_vers");
puts(getenv("SCRIPT_SRC_PATH"));
puts(getenv("VERSION_LANGUAGE"));
}
There's 10 putenvf()s here, and valgrind reports 10 leaks:
==3553116== Memcheck, a memory error detector
==3553116== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==3553116== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==3553116== Command: ./val
==3553116==
/gaming
Perl/AC_perl_vers
==3553116==
==3553116== HEAP SUMMARY:
==3553116== in use at exit: 282 bytes in 10 blocks
==3553116== total heap usage: 31 allocs, 21 frees, 8,618 bytes allocated
==3553116==
==3553116== 22 bytes in 1 blocks are definitely lost in loss record 1 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x1090D2: main (val.c:16)
==3553116==
==3553116== 22 bytes in 1 blocks are definitely lost in loss record 2 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x109120: main (val.c:20)
==3553116==
==3553116== 22 bytes in 1 blocks are definitely lost in loss record 3 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x109135: main (val.c:21)
==3553116==
==3553116== 24 bytes in 1 blocks are definitely lost in loss record 4 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x1090AC: main (val.c:14)
==3553116==
==3553116== 26 bytes in 1 blocks are definitely lost in loss record 5 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x10910D: main (val.c:19)
==3553116==
==3553116== 27 bytes in 1 blocks are definitely lost in loss record 6 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x1090F8: main (val.c:18)
==3553116==
==3553116== 28 bytes in 1 blocks are definitely lost in loss record 7 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x1090BD: main (val.c:15)
==3553116==
==3553116== 30 bytes in 1 blocks are definitely lost in loss record 8 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x1090E7: main (val.c:17)
==3553116==
==3553116== 35 bytes in 1 blocks are definitely lost in loss record 9 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x10915F: main (val.c:23)
==3553116==
==3553116== 46 bytes in 1 blocks are definitely lost in loss record 10 of 10
==3553116== at 0x48407B4: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3553116== by 0x48E6427: __vasprintf_internal (vasprintf.c:71)
==3553116== by 0x109329: putenvf (val.c:9)
==3553116== by 0x10914A: main (val.c:22)
==3553116==
==3553116== LEAK SUMMARY:
==3553116== definitely lost: 282 bytes in 10 blocks
==3553116== indirectly lost: 0 bytes in 0 blocks
==3553116== possibly lost: 0 bytes in 0 blocks
==3553116== still reachable: 0 bytes in 0 blocks
==3553116== suppressed: 0 bytes in 0 blocks
==3553116==
==3553116== For lists of detected and suppressed errors, rerun with: -s
==3553116== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 0 from 0)
Naturally, none of these were leaked, and all are still reachable,
as demonstrated by the puts(getenv(s at the end.
Best,
-- System Information:
Debian Release: 12.4
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500,
'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.1.0-12-amd64 (SMP w/24 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND,
TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages valgrind depends on:
ii libc6 2.36-9+deb12u4
ii libc6-dbg 2.36-9+deb12u4
Versions of packages valgrind recommends:
ii gdb 13.1-3
pn valgrind-dbg <none>
Versions of packages valgrind suggests:
pn alleyoop <none>
pn kcachegrind <none>
pn valgrind-mpi <none>
pn valkyrie <none>
-- no debconf information
signature.asc
Description: PGP signature

