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

Fix stack overflow when generating debuginfo for 'recursive' type #59446

Merged
merged 6 commits into from
Apr 2, 2019

Commits on Apr 1, 2019

  1. Fix stack overflow when generating debuginfo for 'recursive' type

    By using 'impl trait', it's possible to create a self-referential
    type as follows:
    
    fn foo() -> impl Copy { foo }
    
    This is a function which returns itself.
    Normally, the signature of this function would be impossible
    to write - it would look like 'fn foo() -> fn() -> fn() ...'
    e.g. a function which returns a function, which returns a function...
    
    Using 'impl trait' allows us to avoid writing this infinitely long
    type. While it's useless for practical purposes, it does compile and run
    
    However, issues arise when we try to generate llvm debuginfo for such a
    type. All 'impl trait' types (e.g. ty::Opaque) are resolved when we
    generate debuginfo, which can lead to us recursing back to the original
    'fn' type when we try to process its return type.
    
    To resolve this, I've modified debuginfo generation to account for these
    kinds of weird types. Unfortunately, there's no 'correct' debuginfo that
    we can generate - 'impl trait' does not exist in debuginfo, and this
    kind of recursive type is impossible to directly represent.
    
    To ensure that we emit *something*, this commit emits dummy
    debuginfo/type names whenever it encounters a self-reference. In
    practice, this should never happen - it's just to ensure that we can
    emit some kind of debuginfo, even if it's not particularly meaningful
    
    Fixes rust-lang#58463
    Aaron1011 committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    512069f View commit details
    Browse the repository at this point in the history
  2. Fix inverted panic check

    Aaron1011 committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    e1837a0 View commit details
    Browse the repository at this point in the history
  3. Add codegen test

    Aaron1011 committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    aed7ec4 View commit details
    Browse the repository at this point in the history
  4. Fix typos

    Aaron1011 committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    c4556a5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d2584e3 View commit details
    Browse the repository at this point in the history
  6. Fix typo

    Aaron1011 committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    c13daeb View commit details
    Browse the repository at this point in the history