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

Two equivalent programs have different segfault behavior #655

Open
Plyb opened this issue Jan 7, 2025 · 0 comments
Open

Two equivalent programs have different segfault behavior #655

Plyb opened this issue Jan 7, 2025 · 0 comments

Comments

@Plyb
Copy link

Plyb commented Jan 7, 2025

I have two versions of a program that should have identical behavior, but one segfaults and the other doesn't.

To reproduce the issue, clone the repository at this commit. You'll need to include the koka community std repository in your include paths.

If you run the koka program unmodified (koka -e -i<path-to-kk-community-std> interpreter.kk), you should just see a bunch of passing tests. However, if you change line 146 in typecheck.kk from throw("Typecheck: case types do not match at " ++ exp_with_pos.exp_with_pos/exp.show) to throw("Typecheck: case types do not match at " ++ exp.show), the program hangs on the final test (possibly stuck in an infinite recursion?) and finally segfaults. exp is defined at this point as val exp = exp_with_pos.exp (exp_with_pos/ implied, see line 54), and exp_with_pos/exp is an automatically generated function, so the two programs should be behaviorally identical.

(note: I'm not sure I fully understand why exp_with_pos/exp is marked as being <exn,div>, or if that is normal for automatically generated accessor functions for structs)

Koka version information:

Koka 3.1.2, 17:56:43 May 30 2024 (ghc release version)
version: 3.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant