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

Debug info for const generics is hashes rather than something nice #115786

Open
RalfJung opened this issue Sep 12, 2023 · 6 comments
Open

Debug info for const generics is hashes rather than something nice #115786

RalfJung opened this issue Sep 12, 2023 · 6 comments
Labels
A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

In #115748 I got a test failure in tests/debuginfo/function-names.rs: function_names::const_generic_fn_non_int<{CONST#ad91263f6d2dd96e}> changed to static fn function_names::const_generic_fn_non_int<{CONST#73a38766b652ae7d}>. That PR leads to some new AllocIds being generated which shifts some IDs around, so it seems like the AllocId are affecting the function name here. @oli-obk was confused by this since with valtrees, shouldn't our function names be stable now? Indeed AllocId are not very stable at all so it seems potentially problematic if they are relevant for function names. The underlying function call is const_generic_fn_non_int::<{ () }> so this is not a very complicated valtree. ;)

Cc @rust-lang/project-const-generics

@RalfJung RalfJung added the F-const_generics `#![feature(const_generics)]` label Sep 12, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 12, 2023
@BoxyUwU BoxyUwU added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 12, 2023
@RalfJung
Copy link
Member Author

Actually I am seeing the name change in #115803 as well, so it's not some alloc ID change, it's... maybe a slightly different representation of the same const value?

@RalfJung
Copy link
Member Author

Mystery solved! It's this hash right here:

_ => {
// If we cannot evaluate the constant to a known type, we fall back
// to emitting a stable hash value of the constant. This isn't very pretty
// but we get a deterministic, virtually unique value for the constant.
//
// Let's only emit 64 bits of the hash value. That should be plenty for
// avoiding collisions and will make the emitted type names shorter.

Now, whether that's expected behavior or not, I cannot say.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 13, 2023

Ah yea... I guess I should check how we render strings. It's probably an issue if we have symbol names that themselves are multiple megabytes large

@RalfJung
Copy link
Member Author

RalfJung commented Sep 14, 2023

Does rust-lang/rfcs#3161 fix this? Not sure if v0 mangling is involved and what happens for old-school mangling (or if old-school mangling is even still a thing).

EDIT: The PR doesn't change the relevant test, so I guess the answer is "no". Are there any plans to completely switch to v0 name mangling, or do we need a similar fix for old name mangling?

@michaelwoerister
Copy link
Member

FYI: these names are part of debuginfo and not related to symbol mangling. Any change to the debuginfo version of these names should be done with care to make sure we don't break GDB, LLDB, NatVis, etc.

@BoxyUwU
Copy link
Member

BoxyUwU commented Jul 2, 2024

cc #126060

@BoxyUwU BoxyUwU changed the title Some const generic function names still have strange hashes Debug info for const generics is hashes rather than something nice Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants