Package: libc6
Version: 2.39-6
Severity: normal

The following program

#include <mcheck.h>
#include <stdio.h>

int main (void)
{
  int r;

  r = mcheck (NULL);
  printf ("%d\n", r);
  return 0;
}

outputs -1, which is incorrect. It should have been 0.

The glibc manual says

  It is too late to begin allocation checking once you have allocated
  anything with ‘malloc’.  So ‘mcheck’ does nothing in that case.
  The function returns ‘-1’ if you call it too late, and ‘0’
  otherwise (when it is successful).

Since there hasn't been any malloc yet, 0 should have been output.

Similarly, the example given in the mcheck(3) man page fails
unexpectedly.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'stable-security'), (500, 'stable-debug'), (500, 'proposed-updates-debug'), 
(500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.7.12-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libc6 depends on:
ii  libgcc-s1  14.2.0-1

Versions of packages libc6 recommends:
ii  libidn2-0  2.3.7-2

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.87
ii  glibc-doc              2.39-6
ii  libc-l10n              2.39-6
pn  libnss-nis             <none>
pn  libnss-nisplus         <none>
ii  locales                2.39-6

-- debconf information:
  glibc/restart-failed:
* libraries/restart-without-asking: true
  glibc/disable-screensaver:
  glibc/upgrade: true
  glibc/restart-services:
  glibc/kernel-not-supported:
  glibc/kernel-too-old:

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to