public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12232] New: setrlimit interferes with malloc
@ 2010-11-18 16:47 bkorb at gnu dot org
  2010-11-18 19:02 ` [Bug libc/12232] " drepper.fsp at gmail dot com
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: bkorb at gnu dot org @ 2010-11-18 16:47 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12232

           Summary: setrlimit interferes with malloc
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: critical
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: bkorb@gnu.org


The following code comes from gnulib.  It often but does
not always fail.  The problem may be in the OS or in
glibc but I cannot tell because _int_malloc() is too
twisty for me to readily follow.

int
main (int argc, char *argv[])
{
  struct rlimit limit;
  int arg;
  int repeat;
  void * memory;
  if (getrlimit (RLIMIT_AS, &limit) < 0)
    return 77;
  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > MAX_ALLOC_TOTAL)
    limit.rlim_max = MAX_ALLOC_TOTAL;
  limit.rlim_cur = limit.rlim_max;
  if (setrlimit (RLIMIT_AS, &limit) < 0)
    return 77;
  memory = malloc (0x88);

By adding this line of code before the "getrlimit" call:
  free (malloc (0x88));

the problem is not seen.  So, if you use malloc() before the
setrlimit call, you are fine.  There is an interaction issue
with possible problems on both sides of the OS/user space divide.


$ uname -a;/lib64/libc.so.6 |head -1;cat /etc/SuSE-release
Linux beethoven 2.6.34.7-0.4-desktop #1 SMP PREEMPT 2010-10-07 19:07:51 +0200
x86_64 x86_64 x86_64 GNU/Linux
GNU C Library stable release version 2.11.2 (20100531), by Roland McGrath et
al.
openSUSE 11.3 (x86_64)
VERSION = 11.3

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-06-30  6:27 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-18 16:47 [Bug libc/12232] New: setrlimit interferes with malloc bkorb at gnu dot org
2010-11-18 19:02 ` [Bug libc/12232] " drepper.fsp at gmail dot com
2010-11-18 20:14 ` bkorb at gnu dot org
2010-11-18 20:27 ` jakub at redhat dot com
2010-11-18 20:39 ` drepper.fsp at gmail dot com
2010-11-18 20:56 ` bkorb at gnu dot org
2010-11-18 21:00 ` bkorb at gnu dot org
2010-11-22 12:38 ` roucaries.bastien+bugs at gmail dot com
2010-11-23 16:00 ` bkorb at gnu dot org
2011-01-07 22:26 ` bkorb at gnu dot org
2011-01-07 23:24 ` bkorb at gnu dot org
2011-01-07 23:31 ` bkorb at gnu dot org
2011-01-08 14:32 ` drepper.fsp at gmail dot com
2011-01-08 21:32 ` roucaries.bastien+bugs at gmail dot com
2011-01-09 17:52 ` bkorb at gnu dot org
2011-01-09 17:53 ` bkorb at gnu dot org
2011-01-09 17:54 ` bkorb at gnu dot org
2011-01-09 18:59 ` bkorb at gnu dot org
2011-01-10  1:25 ` bkorb at gnu dot org
2011-01-10  3:19 ` drepper.fsp at gmail dot com
2011-01-10 16:00 ` bkorb at gnu dot org
2014-06-30  6:27 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).