Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 58006 - "limit datasize" does not work
"limit datasize" does not work
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-01-04 19:34 EST by Jamie Zawinski
Modified: 2016-11-24 10:12 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-08-26 00:19:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
malloc-bomb.c source: program that verbosely allocates memory (1.23 KB, text/plain)
2002-01-04 19:35 EST, Jamie Zawinski
no flags Details
limiter.pl -- program to demonstrate that setrlimit() works correctly (2.04 KB, text/plain)
2002-01-04 19:36 EST, Jamie Zawinski
no flags Details

  None (edit)
Description Jamie Zawinski 2002-01-04 19:34:05 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.9-13smp i686; Nav)

Description of problem:
"limit datasize 10m" should limit the sbrk+stack size to 10M in tcsh;
programs
that try to brk beyond that should fail (causing brk/malloc to return 0.)

This does not work in tcsh 6.10; tested on Red Hat 6.2, 7.0, and 7.2.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. tcsh
2. limit datasize 5m
3. ./malloc-bomb
	

Actual Results:  Program continues allocating memory forever.

Expected Results:  Program should have died after allocating around 5M.

Additional info:

Attached is the source to the malloc-bomb program I used to test this.
Following that is the source to limiter.pl, a perl script that *does*
work ("./limiter.pl 5M malloc-bomb").  That limiter.pl works demonstrates
that the problem is with tcsh and not with the setrlimit() syscall.

FWIW, bash 1.14 also had this problem, but it appears to have been
corrected by bash 2.04.
Comment 1 Jamie Zawinski 2002-01-04 19:35:23 EST
Created attachment 41831 [details]
malloc-bomb.c source: program that verbosely allocates memory
Comment 2 Jamie Zawinski 2002-01-04 19:36:33 EST
Created attachment 41832 [details]
limiter.pl -- program to demonstrate that setrlimit() works correctly
Comment 3 Miloslav Trmač 2004-08-18 11:41:33 EDT
The difference is that limiter.pl (and (ulimit -v) referenced
in malloc-bomb.c) use RLIMIT_AS, but (limit datasize) uses
RLIMIT_DATA. If you use (limit vmemoryuse) under tcsh
(to also use RLIMIT_AS), bash and tcsh behave exactly the same.


OTOH SUSv3 specifies:
       RLIMIT_DATA
              This is the maximum size of a process’ data segment,  in
 bytes.
              If this limit is exceeded, the malloc() function shall
fail with
              errno set to [ENOMEM].

In fact, RLIMIT_DATA limits memory allocated through sbrk (),
but malloc () in glibc can also use mmap (). This seems like a
violation of the standard by glibc.
Comment 4 Ulrich Drepper 2004-08-26 00:19:17 EDT
That POSIX text is ancient.  If one insists to have this definition of
RLIMIT_DATA, simply start the application with

  MALLOC_MMAP_THRESHOLD_=0

in the environment.  That is perfectly fine with POSIX.  POSIX
specifies only that there must be one environment in which all the
rules apply.  The default environment does not have this stupid
limitation which nobody wants.

Note You need to log in before you can comment on or make changes to this bug.