| Ilya Zakharevich on Fri, 27 Jun 2003 09:10:32 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: system() limitation |
On Fri, Jun 27, 2003 at 10:45:33AM -0400, Igor Schein wrote:
> > > ? system("echo "vector(43204,x,1)"|wc -c")
> > > 129613
> > > ? system("echo "vector(43205,x,1)"|wc -c")
> > > Looks like a silent buffer overflow to me. Maybe the maximum buffer
> > > size allowed should be documented?
> >
> > How can PARI know the limitations of the shell you are currently using?
>
> This is not a shell limitation:
>
> % echo `echo 'vector(1000000,x,1)' | gp -q`|wc -c
> 3000001
Again: you are comparing the shell PARI uses with one you use. They
can easily be different.
Here (Solaris) the limit is close to
? system("echo "vector(343205,x,1)"|wc -c")
1029616
And /bin/sh can handle your example with vector(1e6) fine. Hmm; maybe
it is a system()/execve() limitation? At least Perl has the same
problem:
perl -wle '$s = join ",", 1..1000000; system "echo $s | wc -c" and die $?'
65280 at -e line 1.
Exit 255
So it *is* an execve() limitation. Of course, when you type things
into your shell, you get the builtin 'echo', so the shell should not
start anything with a long command line.
/bin/echo `echo 'vector(1000000,x,1)' | gp -s 128M -q` | wc -c
/bin/echo: Arg list too long.
0
Exit 1
Hope this helps,
Ilya