Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.bugs.dist > #1309484

Bug#1146373: linux-libc-dev: sbrk(2) allocates more than memory + swap space

From Uwe Kleine-König <ukleinek@debian.org>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#1146373: linux-libc-dev: sbrk(2) allocates more than memory + swap space
Date 2026-09-16 20:50 +0200
Message-ID <NE2RH-hzYt-1@gated-at.bofh.it> (permalink)
References <NyhTr-erc9-5@gated-at.bofh.it> <NyhTr-erc9-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Cross-posted to 2 groups.

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello Carl,

On Mon, Aug 31, 2026 at 12:23:35PM -0700, Carl Wuebker wrote:
> Package: linux-libc-dev
> Version: 6.12.107-1
> Severity: normal
> Dear Maintainer,
> 
>   The problem is that sbrk(2) checks each new request against the machine's
> total RAM + swap space.  It should check each new request against total RAM
> + swap space - memory that has already been allocated to the current
> process.
> 
> Steps to reproduce:
> 1. Compile & run the program below on a machine with 32 GiB memory & 24 GiB
> swap
> 
> --- eatmem_bad.c
> #include <stdio.h>
> #include <unistd.h>
> 
> intptr_t bigMem = (intptr_t) 128LL*1024*1024*1024;
> 
> int main(int argc,char *argv[]) {
>     intptr_t i;
>     unsigned long long mem;
> 
>     if (argc != 1)
>         { (void) fprintf(stderr,"Usage: %s\n", argv[0]); return 2; }
> 
>     mem=0;
>     for (i = bigMem; i >= 16; i /= 2)
>         if (sbrk(i) != (void *) -1)
>             mem |= i;
> 
>     (void) printf("Memory=%llu MiB\n",mem / (1024*1024));
> 
>     return 0;
>     }
> ---
> 
> Expected (and correct) result:
> Memory=56718 MiB
> 
> Actual result:
> Memory=65535 MiB

I wonder what your actual problem is.

It's quite usual that a process can get more memory assigned than there
is physically available. That's called "overcommitting" if you want to
research about that.

Unless there is a real problem to solve I suggest to either ignore it or
discuss with upstream what to do.

Best regards
Uwe

Back to linux.debian.bugs.dist | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Bug#1146373: linux-libc-dev: sbrk(2) allocates more than memory + swap space Carl Wuebker <office@wuebker.com> - 2026-08-31 23:40 +0200
  Bug#1146373: linux-libc-dev: sbrk(2) allocates more than memory + swap space Uwe Kleine-König <ukleinek@debian.org> - 2026-09-16 20:50 +0200

csiph-web