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

Expanding recurse EQUS "recurse" or recurse EQUS "\{recurse\}" hangs rgbasm #696

Closed
Rangi42 opened this issue Jan 11, 2021 · 3 comments · Fixed by #839
Closed

Expanding recurse EQUS "recurse" or recurse EQUS "\{recurse\}" hangs rgbasm #696

Rangi42 opened this issue Jan 11, 2021 · 3 comments · Fixed by #839
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Jan 11, 2021

This was noted in #557:

tokens that end precisely at the end of an EQUS are not reported as coming from within the EQUS. It means that recurse EQUS "recurse" does infinitely hang RGBASM.

@ISSOtm ISSOtm added bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM labels Jan 14, 2021
@Rangi42
Copy link
Contributor Author

Rangi42 commented Mar 3, 2021

A more visible example: this stops after the recursion limit due to the newline at the end of recurse:

n = 0
recurse EQUS """
println n
n = n + 1
 recurse
"""
 recurse

But this recurses infinitely:

n = 0
recurse EQUS """
println n
n = n + 1
 recurse"""
 recurse

@Rangi42 Rangi42 changed the title Expanding recurse EQUS "recurse" hangs rgbasm Expanding recurse EQUS "recurse" or recurse EQUS "\{recurse\}" hangs rgbasm Mar 23, 2021
@Rangi42
Copy link
Contributor Author

Rangi42 commented Mar 23, 2021

This problem exists with interpolation as well as EQUS expansion: recurse EQUS "\{recurse\}" will also loop forever.

I don't think it can happen with macro args (the third kind of expansion) because they can't be recursive.

@Rangi42
Copy link
Contributor Author

Rangi42 commented Apr 16, 2021

#829 has some comments regarding a possible fix, if expansions stay unfreed even at the moment they're left, i.e. when exp->offset == exp->size. This would need to handle going back to the top-level correctly, and potentially free a whole nesting of expansions at once.

Rangi42 added a commit to Rangi42/rgbds that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes gbdev#696
Rangi42 added a commit to Rangi42/rgbds that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes gbdev#696
Rangi42 added a commit to Rangi42/rgbds that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes gbdev#696
Rangi42 added a commit to Rangi42/rgbds that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes gbdev#696
Rangi42 added a commit to Rangi42/rgbds that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes gbdev#696
Rangi42 added a commit that referenced this issue Apr 17, 2021
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.

Fixes #696
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants