apparent memory leak using posix_memalign

Bug #1844785 reported by DGelling
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

when allocating and deallocating memory of sufficient size with posix_memalign while keeping smaller allocations done with malloc, a memory leak happens. This only appears when using certain ranges of allocation sizes, and can cause the system to lock up when running out of memory while only having a few megabytes allocated on a 16GB ram machine.

lsb_release -rd:

Description: Ubuntu 18.04.3 LTS
Release: 18.04

apt-cache policy libc6:

libc6:
  Installed: 2.27-3ubuntu1
  Candidate: 2.27-3ubuntu1
  Version table:
 *** 2.27-3ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

see attached for a small program that will trigger the memory leak

I have not tried this on other distros, so don't know if this is ubuntu specific

Revision history for this message
DGelling (dgelling) wrote :
Revision history for this message
DGelling (dgelling) wrote :

Forgot to add:

I compiled with gcc 7.4:

gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

using the following command line:

$ gcc -O0 -g -o memleak memleak.c

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.