FS#45987 - [make] doesn't split arguments along MAX_ARG_STRLEN in linux/binfmts.h
Attached to Project:
Arch Linux
Opened by Jeff Mickey (codemac) - Friday, 14 August 2015, 19:03 GMT
Last edited by Allan McRae (Allan) - Saturday, 14 January 2017, 07:34 GMT
Opened by Jeff Mickey (codemac) - Friday, 14 August 2015, 19:03 GMT
Last edited by Allan McRae (Allan) - Saturday, 14 January 2017, 07:34 GMT
|
Details
Description:
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 4611686018427387903 ; 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> int main() { printf("ARG_MAX: %ld\n", sysconf(_SC_ARG_MAX)); printf("PAGESIZE: %ld\n", sysconf(_SC_PAGESIZE)); } ^D ; gcc test.c && ./a.out ARG_MAX: 4611686018427387903 PAGESIZE: 4096 ; Additional info: make 4.1-1 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. I'm also filing a bug against upstream (gnu make), but I don't know their bug policies or how likely they'll be fixing this. Will post a link as a comment to the issue once I have it. |
This task depends upon
Comment by Jeff Mickey (codemac) -
Friday, 14 August 2015, 19:07 GMT
Comment by Jeff Mickey (codemac) -
Tuesday, 02 February 2016, 19:21 GMT
Comment by Allan McRae (Allan) -
Saturday, 20 February 2016, 02:31 GMT
https://savannah.gnu.org/bugs/?45763
The upstream bug has not been looked into yet, Arch should
seriously consider patching make IMO
I'll see if I can get traction upstream. Patches with typos in the
subject line don't convince me to apply non-upstream patches.