Incomplete/wrong debuginfo for references and pointers to slice-like unsized types #92718
Labels
A-debuginfo
Area: Debugging information in compiled programs (DWARF, PDB, etc.)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
References and pointers to unsized types are "fat" which means that they hold not just the address of the pointee but also an additional field that contains either the size of the pointee's unsized field (for slice-like pointees) or the addr of the vtable (for trait object pointers).
The compiler generates debuginfo for this additional field in most cases (e.g. for
&[T]
and*mut [T]
) -- but if the pointee is an unsized struct then the compiler generates regular thin pointer debuginfo which does not describe the additional field.Example:
The debuginfo for
&[u64]
looks as expected:But
&SomeUnsizedType
does not have the additional field:The last field is described as a zero-sized array
[u8; 0]
. As a consequence, a debugger has no way of finding out how many elements the field actually holds. This affects a number of common types from the standard library, likeRc
,Arc
,CStr
which all use unsized structs internally.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: