-
Notifications
You must be signed in to change notification settings - Fork 13k
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
CTFE fails to detect a certain class of infinite loops #52475
Comments
I decided to give a stab at fixing this issue and I believe I made some good progress, my WIP is in #52626. So far I managed to generalize the implementation of @ecstatic-morse did you get to start implementing a fix as well? Maybe we could complement each other's work. |
I haven't gotten started yet; I don't have as much free time as I thought 😄. I'll look at what you have so far though! |
Fix issue #52475: Make loop detector only consider reachable memory As [suggested](#51702 (comment)) by @oli-obk `alloc_id`s should be ignored by traversing all `Allocation`s in interpreter memory at a given moment in time, beginning by `ByRef` locals in the stack. - [x] Generalize the implementation of `Hash` for `EvalSnapshot` to traverse `Allocation`s - [x] Generalize the implementation of `PartialEq` for `EvalSnapshot` to traverse `Allocation`s - [x] Commit regression tests Fixes #52626 Fixes #52849
@ecstatic-morse This can be closed, right? The PR that fixes this (according to its description) has long been merged. |
I haven't looked at that PR, but it seems like the test is passing, so let's close this. |
#51702 implemented a limited form of infinite loop detection during const evaluation by periodically comparing MIR interpreter states.
Currently, the detector considers
AllocId
s when comparing interpreter memory. It is possible for two interpreter states which have differentAllocId
s to be functionally equivalent if the underlying allocations have the same structure and values. For example, the following code, which could easily be terminated by the infinite loop detector, causes const evaluation to continue forever.This hangs the current nightly build (2017-07-16).
@oli-obk suggested to ignore
AllocId
s by traversing all allocations in interpreter memory at a given moment in time in a predictable order. If two traversals observe logically equivalentAllocation
s in the same order, the interpreter state as a whole is logically equivalent as well.I have some free time again, so I'll try to implement this.
The text was updated successfully, but these errors were encountered: