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

Debugger call stack lost upon entering compiler-emitted __$hasher function #4823

Open
bplu4t2f opened this issue Feb 10, 2025 · 0 comments
Open

Comments

@bplu4t2f
Copy link

Context

When debugging into the hasher function used by map when setting a value, the call stack is lost after executing the prologue sub rsp,38h upon entering the __$hasher function.

I would consider this low-priority as it its impact is relatively insignificant.

I'm reporting this mainly because I believe this is because Odin doesn't generate proper unwind table information in the PDB in this particular case, and if this is true and if this is unintentional, there might be other emits affected by this bug, where it actually does matter.

I have not been able to find any resources mentioning whether this is intentional or not.

  • Operating System & Odin Version:
    Odin: dev-2025-01-nightly:2aae4cf
    OS: Windows 10 Professional (version: 22H2), build 19045.5371
    CPU: 12th Gen Intel(R) Core(TM) i5-12600KF
    RAM: 32627 MiB
    Backend: LLVM 18.1.8

Compiled with -debug -o:none.

Expected Behavior

Preserve the call stack all the way into the actual hasher.

Current Behavior

00007FF78D98B9A0  sub         rsp,38h  
00007FF78D98B9A4  mov         qword ptr [rsp+28h],rdx                     ; CALL STACK GONE from here on
00007FF78D98B9A9  mov         qword ptr [rsp+30h],rcx  
00007FF78D98B9AE  jmp         __$hasher1+10h (07FF78D98B9B0h)  
00007FF78D98B9B0  mov         rdx,qword ptr [rsp+28h]  
00007FF78D98B9B5  mov         rcx,qword ptr [rsp+30h]  
00007FF78D98B9BA  call        runtime.default_hasher_string (07FF78D9894A0h)  
00007FF78D98B9BF  add         rsp,38h                                     ; call stack is good again after this executes
00007FF78D98B9C3  ret  

Failure Information (for bugs)

Was able to reproduce in Visual Studio's native debugger, and cppvsdbg in vscode.

I'm not seeing frame pointers anywhere, and I haven't seen any option to disable (or not disable) frame pointers.
So I'm assuming Odin just isn't using them in its codegen, and is relying fully on unwind tables in the PDB, and debugger heuristics.

Steps to Reproduce

package main

main :: proc() {
    dat := make(map[string]int)
    defer delete(dat)
    dat["hello"] = 5
}

Debug into the call instruction to __$hasher1 that's emitted for the line dat["hello"] = 5
OR
Set a breakpoint inside default_hasher_string in dynamic_map_internal.odin.

Observe that the main proc, and everything before it, is gone from the call stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant