kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

contrived borderline case #509

Closed tavmem closed 4 years ago

tavmem commented 6 years ago

Although this seems a somewhat contrived borderline case, kona should not crash. In kona:

$ rlwrap -n ~/kona/k
kona      \ for help. \\ to exit.

  a:_n
  a:a//,//
  a?#a
Segmentation fault (core dumped)

in k2.8:

$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.

  a:_n
  a:a//,//
  a?#a
nonce error
{[f;y;x]u:_abs 1e-6*y+y=0;d:1e-4*x+x=0;t:y-f x;do[20;r:t;d*:t%r-t:y-f x+:d;if[&/u>_abs t;:x+d]];'`limit}
                                           ^
>  
tavmem commented 6 years ago

BTW: this can be simplified a bit in k2.8:

$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.

  a:_n
  a:a//,//
  a?1
nonce error
{[f;y;x]u:_abs 1e-6*y+y=0;d:1e-4*x+x=0;t:y-f x;do[20;r:t;d*:t%r-t:y-f x+:d;if[&/u>_abs t;:x+d]];'`limit}
                                           ^
> 

Crash in kona.

tavmem commented 4 years ago

These no longer crash ... but do not yield similar results to k2.8, yet.

kona      \ for help. \\ to exit.

  a:_n
  a:a//,//
  a?#a
1.0
kona      \ for help. \\ to exit.

  a:_n
  a:a//,//
  a?1
1.0
tavmem commented 4 years ago

simpler:

K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
\ for help. \\ to exit.

  (_n,//,//)?1
type error
{[f;y;x]u:_abs 1e-6*y+y=0;d:1e-4*x+x=0;t:y-f x;do[20;r:t;d*:t%r-t:y-f x+:d;if[&/u>_abs t;:x+d]];'`limit}
                                           ^
>  
kona      \ for help. \\ to exit.

  (_n//,//)?1
1.0
tavmem commented 4 years ago

oops: last post changed the error message from k2.8 (making it a different issue):

K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
\ for help. \\ to exit.

  (_n//,//)?1
nonce error
{[f;y;x]u:_abs 1e-6*y+y=0;d:1e-4*x+x=0;t:y-f x;do[20;r:t;d*:t%r-t:y-f x+:d;if[&/u>_abs t;:x+d]];'`limit}
                                           ^
> 
kona      \ for help. \\ to exit.

  (_n//,//)?1
1.0
tavmem commented 4 years ago
kona      \ for help. \\ to exit.

  (_n//,//)?1
nonce error
> 
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
\ for help. \\ to exit.

  (_n//,//)?1
nonce error
{[f;y;x]u:_abs 1e-6*y+y=0;d:1e-4*x+x=0;t:y-f x;do[20;r:t;d*:t%r-t:y-f x+:d;if[&/u>_abs t;:x+d]];'`limit}
                                           ^
>