Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instability #623

Closed
john1761 opened this issue Feb 22, 2022 · 5 comments
Closed

Instability #623

john1761 opened this issue Feb 22, 2022 · 5 comments
Labels

Comments

@john1761
Copy link

There appears to be an instability. As far as I can tell it requires:

  • an inner function which uses the over adverb
  • an outer function which calls the inner function at least twice

This seems to be a regression in that the behaviour was not present in interpreters up until early 2019. I am currently using windows only, I do not know if it exists on other platforms.

Example; bug.k:

s:{+/!x}         / needs to include the '/ over' adverb, any verb will do
test:{s[x]+s[x]} / needs to call the other function at least twice

_k               / version check - appears to regress in 2019
/s[3]            / uncomment this line and the program does not crash.
"before"
test 3
"after"

produces output:

C:\bin\k : k.exe bug.k
kona      \ for help. \\ to exit.

"2021-12-24"
"before"

C:\bin\k :

The 'after' is not displayed and buried in the windows event log is an unhelpful message about a crash.

Oddly, calling the inner function from global scope before it is called from function scope appears to prevent the crash. Presumably it is accidentally tidying a memory issue?

@gitonthescene
Copy link

gitonthescene commented Feb 23, 2022

I tested on macOS and I also get the crash with the line commented and not without.

➜  kona git:(master) ✗ ./k bug.k 
kona      \ for help. \\ to exit.

"2021-12-06"
"before"
[1]    72342 segmentation fault  ./k bug.k
➜  kona git:(master) ✗ uname -a
Darwin Macintosh.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
➜  kona git:(master) ✗ 

Just to make it easier, I've attached the script (with the suffix changed): bug.k.txt

Running git bisect with this file, I got the following:

$ git bisect good; make; ./k bug.k
1f02a068912106f8f1f8cc14e0914aceb911877e is the first bad commit
commit 1f02a068912106f8f1f8cc14e0914aceb911877e
Author: Tom Szczesny <[email protected]>
Date:   Wed May 15 16:19:57 2019 -0400

    pass dict by value

 src/kx.c |  2 +-
 src/kx.h |  2 +-
 src/p.c  | 26 +++++++++++++-------------
 src/p.h  |  4 ++--
 src/v.c  |  2 +-
 src/v.h  |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)
make: Nothing to be done for `all'.
kona      \ for help. \\ to exit.

  "2021-12-06"
"before"
6
"after"
$

@tavmem tavmem added the crash label Mar 15, 2022
@tavmem
Copy link
Collaborator

tavmem commented Aug 31, 2022

Got a similar result in Linux on kona

$ ./k bug.k 
kona      \ for help. \\ to exit.

"2022-08-30"
"before"
Segmentation fault (core dumped)

@tavmem
Copy link
Collaborator

tavmem commented Aug 31, 2022

in k2.8

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

"2.8"
"before"
6
"after"

@tavmem
Copy link
Collaborator

tavmem commented Aug 31, 2022

The problem first appears in the commit of Sep 1, 2019
which was made by TomDuCoin
to fix issue #521: Recursive call overrides earlier data

In all fairness:
the 9/1/19 commit does indeed resolve issue #521
The "instability" appears to be a side effect of the #521 fix.

@tavmem
Copy link
Collaborator

tavmem commented Aug 31, 2022

This area of the code was then modified further (by me) in the commit of Nov 2, 2019
titled "fix #566 and fix #549: recursions housed in subfunctions"
Obviously, the "instability" side effect remained.

@tavmem tavmem closed this as completed in 8a82bc6 Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants