[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #45763] Split args along MAX_ARG_STRLEN for linux/posix

From: anonymous
Subject: [bug #45763] Split args along MAX_ARG_STRLEN for linux/posix
Date: Fri, 14 Aug 2015 19:06:32 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0


                 Summary: Split args along MAX_ARG_STRLEN for linux/posix
                 Project: make
            Submitted by: None
            Submitted on: Fri 14 Aug 2015 07:06:31 PM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.1
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None



When you run a make command where one of the targets has a sufficiently large
enough arg list, you get:

make: execvp: /bin/sh: Argument list too long

This is because in GNU make they don't split arguments to /bin/sh in their
$(shell) directive, so it's just /bin/sh -c "everything". This is running into
MAX_ARG_STRLEN, and the debian patch definitely fixes it.

On debian they patch this to split along the pagesize so you can execute
things of arbitrary length arguments. I've attached the patch that debian uses
in their current package of make (4.0). My limits.h has things like stacksize
set to unlimited, which means the following:

; getconf ARG_MAX
; cat /usr/include/linux/limits.h | grep ARG_MAX
#define ARG_MAX       131072    /* # bytes of args + environ for exec() */
; grep -HIins MAX_ARG_STRLEN /usr/include/linux/binfmts.h
/usr/include/linux/binfmts.h:10: * execve() system call.  MAX_ARG_STRLEN is
essentially random but serves to
/usr/include/linux/binfmts.h:14:#define MAX_ARG_STRLEN (PAGE_SIZE * 32)
; cat > test.c
#include <stdio.h>
#include <unistd.h>
main() {
    printf("ARG_MAX: %ld\n", sysconf(_SC_ARG_MAX));
    printf("PAGESIZE: %ld\n", sysconf(_SC_PAGESIZE));
; gcc test.c && ./a.out
ARG_MAX: 4611686018427387903

Steps to reproduce:
Create a makefile with the following contents:

ALL_FILES := $(shell / -type f)
ECHO_FILES := echo $(ALL_FILES) | fmt -1

all: $(shell /bin/bash $(ECHO_FILES))
        ls /

Name it 'makefile.test' or something, and then run:

make -f makefile.test all

And you'll see it print the error message.


Debian has a patch that fixes this behavior, see my attachment.


File Attachments:

Date: Fri 14 Aug 2015 07:06:31 PM UTC  Name:
0009-handle_excessive_command_length-Patch-to-fix-large-c.patch  Size: 4kB  
By: None
debian patch to make for long argument


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]