bug-gawk
[Top][All Lists]
Advanced

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

Re: A naughty function call


From: arnold
Subject: Re: A naughty function call
Date: Mon, 19 Jul 2021 01:36:31 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Buy more RAM.

You are running up against the GNU "No Arbitrary Limits" principle,
combined with the fact that Linux (?) isn't returning failure from
malloc but instead decides to the kill the process.

In short, there's nothing I can do in this situation.

Arnold

Wolfgang Laun <wolfgang.laun@gmail.com> wrote:

> function srep(n, s){
>     n *= length(s)
>     if( n == 0 ) return ""
>     while( length(s) < n ) {
>         s = s s;
>     return substr( s, 1, n );
> }
> BEGIN { x = srep( 200000000, "abc" ); } # to measure performance
>
> On my Linux box running GNU Awk 5.0.1, the execution fails:
> $ gawk -f srepDoubl.awk
> Killed
>
> In this simple example, it is immediately clear to the programmer that
> memory allocation fails. But is this the intended diagnostic? I think it
> might be a little more user-friendly.
>
> Cheers
> Wolfgang
>
> PS: It seems preferable to measure the performance using repeated
> executions of the function call with *reasonable *parameter combinations.



reply via email to

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