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

Do a volatile read in stack_overflow test to avoid tail recursion #818

Merged
merged 1 commit into from
Jun 8, 2020

Conversation

phil-opp
Copy link
Owner

@phil-opp phil-opp commented Jun 8, 2020

This prevents the compiler from transforming the tail recursive function into a loop, which does not lead to a stack overflow. It also avoids the LLVM bug where functions with side-effect-free endless loops are removed. Thus, the test now also works in --release mode.

Post update in #820.

Suggested by @bjorn3 in #449 (comment).

@phil-opp phil-opp force-pushed the post-06-prevent-tail-recursion branch from 7eb1b63 to fd88ae5 Compare June 8, 2020 10:13
@phil-opp phil-opp changed the title post 06 prevent tail recursion Do a volatile read in stack_overflow test to avoid tail recursion Jun 8, 2020
@phil-opp phil-opp added the relnotes "Release notes" – Notable changes that are rendered on the blog. label Jun 8, 2020
This prevents the compiler from transforming the tail recursive function into a loop, which does not lead to a stack overflow. It also avoids the LLVM bug where functions with side-effect-free endless loops are removed. Thus, the test now also works in `--release` mode.
@phil-opp phil-opp force-pushed the post-06-prevent-tail-recursion branch from fd88ae5 to 5735cb8 Compare June 8, 2020 10:17
phil-opp added a commit that referenced this pull request Jun 8, 2020
Adds a dummy volatile read in the stack_overflow test to ensure that it is not tail recursive. Thus, the compiler can't apply the tail call elimination optimization, which turns the recursive function into a loop and thus prevents the stack overflow from happening.

Code update in #818.
@phil-opp phil-opp merged commit 0dd32e2 into post-06 Jun 8, 2020
@phil-opp phil-opp deleted the post-06-prevent-tail-recursion branch June 8, 2020 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes "Release notes" – Notable changes that are rendered on the blog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant