I am debugging someone else's code, and I am faced with a situation that I do not know how to produce if I try to program it intentionally. It comes from a very large Bash script, which is executed by Bash 4.1.2 in the CentOS 6 field. Although the general program is gigantic, an error occurs sequentially in the following function:
get_las() { echo "Getting LAS..." pushd ${ferret_workdir} >& /dev/null #Download: if [ ! -e ${las_dist_file} ] || ((force_install)) ; then echo "Don't see LAS tar file ${las_dist_file}" echo "Downloading LAS from ${las_dist_file} -to-> $(pwd)/${las_dist_file}" echo "wget -O '${las_dist_file}' '${las_tar_url}'" wget -O "${las_dist_file}" "${las_tar_url}" [ $? != 0 ] && echo " ERROR: Could not download LAS:${las_dist_file}" && popd >/dev/null && checked_done 1 fi popd >& /dev/null return 0 }
If I allow the script to run from scratch in an untouched environment when this section is reached, it will spit out the following error and die:
Don't see LAS tar file las-esg-v7.3.9.tar.gz Downloading LAS from las-esg-v7.3.9.tar.gz -to-> /usr/local/src/esgf/workbench/esg/ferret/7.3.9/las-esg-v7.3.9.tar.gz wget -O 'las-esg-v7.3.9.tar.gz' 'ftp://ftp.pmel.noaa.gov/pub/las/las-esg-v7.3.9.tar.gz' /usr/local/bin/esg-product-server: line 428: /usr/bin/wget: Argument list too long ERROR: Could not download LAS:las-esg-v7.3.9.tar.gz
Note that I even have a debugging echo to prove that the arguments are only two small lines.
If I made a program error at the point above, and then immediately ran it from the same expected script, the only change was that he had already completed all the steps before that and found that skipping them, this section will usually be executed without mistakes. This behavior is 100% reproducible in my test box - if I clear all traces that run the code, the first run after that will be bombed at this point, and subsequent runs will be fine.
The only thing I can think of is that I came across some kind of obscure error in Bash itself that somehow causes its memory leak MAX_ARG_PAGES unnoticed, but I canβt think of any theoretical ways to do this, so I ask here.
What happens, and how can I make it stop (without extreme measures, such as recompiling the kernel to just add more memory to it)?
Update: To answer the question in the comments, line 428
wget -O "${las_dist_file}" "${las_tar_url}"