odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
7k stars 620 forks source link

silent crash (stack overflow?) when copying small parts of large structs back to themselves #3309

Open beaumccartney opened 8 months ago

beaumccartney commented 8 months ago

Context

    Odin:    dev-2024-03:7d6e9ef39
    OS:      Windows 11 Home Basic (version: 22H2), build 22621.3155
    CPU:     AMD Ryzen 9 5950X 16-Core Processor
    RAM:     32666 MiB
    Backend: LLVM 17.0.1

Bug

on windows with certain large structs, clearing them to zero while copying some of their fields back in silently crashes. I've not been able to reproduce this issue on my mac.

e.g.

// silently crashes
gamestate^ = {
    persistent = gamestate.persistent
}

factoring out to below fixes the crash for me

persistent := gamestate.persistent
gamestate^ = {}
gamestate.persistent = persistent

Unfortunately I don't have a minimal repro. I'll continue searching for one and update here if I find one.

beaumccartney commented 8 months ago

i ran it in rad debugger and got this

image

perhaps I don't have all the visual studio things installed that I'm supposed to (god help me) but I don't have a d drive either

beaumccartney commented 8 months ago

I switched to using PortableBuildTools and I'm still having the same issue so I'm not confident its a VS install issue anymore

flysand7 commented 8 months ago

That sounds like either a rad debugger issue or something else. Are you building your project with -no-crt?

beaumccartney commented 8 months ago

I'm using libc rn, so using no-crt isn't an option rn

I tried in rememdybg too and I got a stack overflow exception. I suppose that tracks cause the struct is large, but what I'm only copying a small field from the large struct and clearing the rest. I'm not entirely sure how this should behave but I don't have this problem on macos.

image

my apologies for changing the issue name, I'll change it back