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

APPLY does not terminate on a circular list #684

Closed
pclouds opened this issue May 3, 2020 · 5 comments
Closed

APPLY does not terminate on a circular list #684

pclouds opened this issue May 3, 2020 · 5 comments

Comments

@pclouds
Copy link
Contributor

pclouds commented May 3, 2020

This is a mirror of ashinn/chibi-scheme#629. While chibi segfaults, Gauche runs forever.

(define x '#0=(a . #0#))
(apply list x)

I looked at the backtrace with gdb and it looks like when GAUCHE_LAZY_PAIR is on, check_arglist_tail_for_apply() does not handle circular list correctly. The other version, which uses Scm_Length(), does handle it and terminates with

*** ERROR: improper list not allowed: #0=(a . #0#)

PS. Gauche cannot be compiled with GAUCHE_LAZY_PAIR set to zero anymore (undefined symbols). Might as well simplify the code and get rid of non-lazy code paths.

@lassik
Copy link
Contributor

lassik commented May 3, 2020

Thanks a lot for testing these cases! It would be really neat to have a survey of how the primitives in different Scheme implementations handle circular lists. schemedoc/surveys?

@pclouds
Copy link
Contributor Author

pclouds commented May 3, 2020

This is a very specific case, I don't think worth surveying. Though if you do, maybe coordinate with John, his wg2 repo tracks which scheme supports what feature for a lot of schemes and features.

@lassik
Copy link
Contributor

lassik commented May 3, 2020

maybe coordinate with John

Definitely. With the docker containers we could even do a simple framework for automated test cases. Send some input to the REPL, expect a particular set of outputs and record the results.

shirok added a commit that referenced this issue May 3, 2020
@shirok
Copy link
Owner

shirok commented May 3, 2020

Good catch. Fix pushed.

We still don't detect if the argument is an infinite lazy list---in which case, the process eventually exhaust memory. But actually, we don't need to realize the lazy list entirely; we only need up to the number of required arguments. That'll be another task.

@pclouds
Copy link
Contributor Author

pclouds commented May 4, 2020

Wow. It's good that I reported instead of attempting to fix myself. I didn't see all that. Since lazy list problem is already tracked, I'll close this one. Thanks!

@pclouds pclouds closed this as completed May 4, 2020
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

3 participants