c - Varying number of maximum arguments, and diffrent failure results -
what maximum number of arguments executable on linux x64 ?
i have reviewed:
- http://www.in-ulm.de/~mascheck/various/argmax/
- https://psomas.wordpress.com/2011/07/15/arg_max-and-the-linux-kernel/
edit: according fs/exec.c 210-216:
/* * limit 1/4-th stack size argv+env strings. * ensures that: * - remaining binfmt code not run out of stack space, * - program have reasonable amount of stack left * work from. */
the stack has soft limit of 8mb, , and no hard limit according ulimit, , getrlimit().
with constant environment variables, , homogeneous arguments (all "1\0"), number of arguments can run program varies. 2 diffrent behaviors when program fails run:
- segfualt
- the string "killed" printed console
the maximum number of arguments can run program goes after previous runs, towards maximum. running program multiple times in row, if haven't exceeded maximum eventaully result in sucess.
in 1 case 838325 arguments, first 2 runs resulted in segfaults, , third sucessful argv + env taking 8384282 bytes including data, , pointers data. 5mb short of full stack, not including stack frames, not no how calculate here. running programming many more arguments, ex 1000000, results in "killed". occationally, smaller number of arguments recieve "killed" result.
- why segfaults?
- why able run program number of arguments , not others?
- why killed result occationally?
- why can't grow stack past ~8mb if stack has no hard limit?
edit: grammar edit2: rephrased
Comments
Post a Comment