Reference cycles can cause infinte loops

Open
#336 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by running the ASL example from the issue and tracing reference resolution at Return (Local3), where the cycle causes the stack overflow. Read issue #313 for related store behavior. Done means cyclic references no longer loop indefinitely or overflow the stack, with a regression test covering the supplied example.

Written by the indexing model from the issue text.

Description

I think this is a low priority for reasons at the end.

The following ASL demonstrates the issue:

DefinitionBlock("", "DSDT", 1, "RSACPI", "Refs", 1) {
    Method(MAIN) {
        Local0 = 1
        Local1 = RefOf(Local0)
        Local2 = RefOf(Local1)
        Local0 = RefOf(Local2)

        // This line doesn't cause an infinite loop, it just stores a reference
        Local3 = Local0

        // The following line causes an infinite loop trying to get the value
        Return (Local3)
    }
}

This actually fails with thread 'main' (19208) has overflowed its stack.

At present it isn't possible to test stores to the cycle (e.g. Local0 = 2 instead of Local3 = Local0), but the fix for issue #313 would unblock this - in that case Stores also cause infinite loops, but without the stack overflow.

Why is this a low priority?

  • Surely no-one would write ASL like this? (insert "right? right?" meme here)
  • uACPI also hangs in this case
  • acpiexec just exits the process with no error messages

So this crate failing is not out line with other implementations (although I didn't test Windows). I think this should be a straightforward fix - just add a loop counter when unwrapping references?

There's a more complex fix - raising errors when trying to create cycles - but IMO it's not worth the extra complexity.

Dominant language
Rust
Stars
249
Forks
102
Avg merge
4d 18h
Merged PRs (30d)
6

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-osdev/acpi

All issues in rust-osdev/acpi

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.