Uh oh!
There was an error while loading. Please reload this page.
Fix stack overflow when generating debuginfo for 'recursive' type - #59446
Conversation
rust-highfive
commented
Mar 26, 2019
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
commented
Mar 26, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
f54b7eb to
c1b9632Compare| // This kind of type cannot be properly represented | ||
| // via LLVM debuginfo. As a workaround, | ||
| // we register a temporary Ty to metadata mapping | ||
| // for the function before we compute its actual metadat.a |
There was a problem hiding this comment.
| // for the function before we compute its actual metadat.a | |
| // for the function before we compute its actual metadata |
| size.bits(), | ||
| align.bits() as u32, | ||
| DW_ATE_unsigned) | ||
There was a problem hiding this comment.
there are a bunch of empty lines here
| // recursing forever. | ||
| // | ||
| // This function is used to remove the temporary metadata | ||
| // mapping after we've computed the actual metadat |
There was a problem hiding this comment.
| // mapping after we've computed the actual metadat | |
| // mapping after we've computed the actual metadata |
| t.fn_sig(cx.tcx), | ||
| usage_site_span).metadata; | ||
| type_map.borrow_mut().remove_type(t); |
There was a problem hiding this comment.
why are we registering this only temporarily and don't just leave it in?
There was a problem hiding this comment.
The temporary metadata is only used in the case where we recurse back to processing the same type.
The actual type will be inserted into the map at the bottom of the function.
Aaron1011
commented
Mar 29, 2019
@oli-obk I've made the changes you requested |
oli-obk
commented
Mar 29, 2019
@bors r+ |
bors
commented
Mar 29, 2019
📌 Commit 50ab958 has been approved by |
…=oli-obk
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
Fixesrust-lang#58463Centril
commented
Mar 30, 2019
Speculatively assigning blame of failure in #59538 (comment), @bors r- |
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
Fixesrust-lang#5846350ab958 to
d2584e3CompareAaron1011
commented
Apr 1, 2019
@Centril: Fixed |
| // (e.g. MyType<fn() -> u8, fn() -> u8> | ||
| // | ||
| // We only care about avoiding recursing | ||
| // directly back to the type we're currentlu |
There was a problem hiding this comment.
typo: "currentlu" should be "currently"
Aaron1011
commented
Apr 1, 2019
@pnkfelix Fixed |
cramertj
commented
Apr 1, 2019
r? @oli-obk |
oli-obk
commented
Apr 2, 2019
bors
commented
Apr 2, 2019
📌 Commit c13daeb has been approved by |
…=oli-obk
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
Fixesrust-lang#58463…=oli-obk
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
Fixesrust-lang#58463Rollup of 4 pull requests Successful merges: - #59166 (resolve: collect trait aliases along with traits) - #59341 (Fix custom relative libdir) - #59446 (Fix stack overflow when generating debuginfo for 'recursive' type) - #59529 (Added documentation on the remainder (Rem) operator for floating points.) Failed merges: r? @ghost
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#58463