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

[SR-3770] Swift REPL: Automatically printed description of indirect enum is incorrect and may cause infinite loop #4643

Closed
swift-ci opened this issue Jan 28, 2017 · 4 comments
Labels
bug Something isn't working LLDB for Swift REPL

Comments

@swift-ci
Copy link

Previous ID SR-3770
Radar None
Original Reporter palle (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

macOS 10.12.3 (16D32),
Swift 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1),
Xcode 8.2.1 (8C1002)

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug, REPL
Assignee jingham@apple.com (JIRA)
Priority Medium

md5: 7c8e8fccab79d40e32bc5bb1aed3238d

is duplicated by:

  • SR-3972 Infinite recursion when defining indirect enums in REPL

Issue Description:

When typing the following code into the Swift REPL (in a Terminal), the Swift REPL goes into an infinite loop trying to print the structural description of a created value:

indirect enum Test {
    case something(Test)
    case end
}
// This line will cause the REPL to go into an infinite loop:
let test = Test.something(Test.something(Test.something(Test.something(Test.end))))

In another case, I have noticed, that some fields in the description may be missing or wrong:

public indirect enum List<Element> {
    case empty
    case element(head: Element, tail: List<Element>)
}
var list = List<Int>.empty
// Everything OK so far
list = List.element(head: 42, tail: list)
// The next line will print an incorrect structural description of the variable list:
list

Some outputs for the last line of the second example are:

$R0: List<Int> = element {
  element = {
    head = 4301270064
    tail = element {
      element = {
        head = -4611677235481463998
        tail = element {
          element = {
            head = 4579621336
            tail = element {
              element = {
                head = 140527134881072
                tail = element {
                  element = {
                    head = 140527134881088
                    tail = element {
                      element = {
                        head = 140527134881088
                        tail = element {
                          element = {
                            head = 4580062912
                            tail = empty
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

or

$R1: List<Int> = element {
  element = {
    head = 4301270064
    tail = element {
      element = {
        head = -8070441749301998876
        tail = empty
      }
    }
  }
}
@belkadan
Copy link

Reproduces on master. @jckarter, is this a known runtime issue, or an issue with mirrors, or something that really is LLDB's fault?

@jckarter
Copy link
Member

I think LLDB does its own handling of these. jingham@apple.com (JIRA User)?

@swift-ci
Copy link
Author

Comment by Jim Ingham (JIRA)

This is a data formatter issue, not specific to the REPL. I'm currently investigating this problem.

@swift-ci
Copy link
Author

swift-ci commented Feb 7, 2017

Comment by Jim Ingham (JIRA)

Fixed by commit 4e15b79413073623fb0b52702773e5addda85814.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift REPL
Projects
None yet
Development

No branches or pull requests

3 participants