This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5786] New: sysconf(_SC_ARG_MAX) no longer accurate since Linux kernel 2.6.23


In Linux 2.6.23, the limit on the size of [argv + environ] became controllable
by the user, based on the RLIMIT_STACK resource limit.  (See the man page
excerpt below.)  Glibc doesn't seem to know this yet -- I'm not even sure
whether it can be made to know it.  Anyway, as things stand, the return value of
sysconf(_SC_ARG_MAX) is no longer accurate (unless I've missed something), and
this report is a heads up on that point.

>From execve.2

   Limits on size of arguments and environment
       Most Unix implementations impose some limit on the  total
       size  of the command-line argument (argv) and environment
       (envp) strings that may  be  passed  to  a  new  program.
       POSIX.1  allows an implementation to advertise this limit
       using the ARG_MAX constant (either defined in  <limits.h>
       or    available    at    run    time   using   the   call
       sysconf(_SC_ARG_MAX)).

       On Linux prior to kernel 2.6.23, the memory used to store
       the  environment  and  argument strings was limited to 32
       pages (defined by the kernel constant MAX_ARG_PAGES).  On
       architectures  with a 4-kB page size, this yields a maxi-
       mum size of 128 kB.

       On kernel 2.6.23 and later, most architectures support  a
       size  limit  derived  from the soft RLIMIT_STACK resource
       limit (see getrlimit(2)) that is in force at the time  of
       the  execve()  call.   For these architectures, the total
       size is limited to 1/4 of the  allowed  stack  size,  the
       limit  per  string  is  32  pages  (the  kernel  constant
       MAX_ARG_STRLEN), and the maximum  number  of  strings  is
       0x7FFFFFFF.   (This change allows programs to have a much
       larger argument and/or environment  list.   Imposing  the
       1/4-limit  ensures  that  the new program always has some
       stack space.)  Architectures with  no  memory  management
       unit  are  excepted:  they maintain the limit that was in
       effect before kernel 2.6.23.

-- 
           Summary: sysconf(_SC_ARG_MAX) no longer accurate since Linux
                    kernel 2.6.23
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: michael dot kerrisk at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]