#LLVM ReadAccessViolation when calling LLVMTargetMachineEmitToFile

1 messages · Page 1 of 1 (latest)

deft salmon
#

Hi, I have been building a game with odin and I encountered a bug with the llvm backend while I was refactoring my code. Unfortunately I have been unable to track the exact cause of the crash yet as I made many changes to my code before recompiling. I did walk through the crash in my debugger and found the exact line that crashes is llvm_backend.cpp:2615, which means that I get no error message because the compiler crashes before it prints anything out. I am unsure what to do as a next step.

simple saffron
#

What platform are you on?

deft salmon
#

I'm on windows x86_64

deft salmon
#

@simple saffron I did some experimenting this morning and I found a way to repro the bug reliably.

package repro

import "core:fmt"

foo: [65536]u8 = foo_init()

foo_init :: proc() -> [65536]u8 {
    return {}
}

foo_deinit :: proc(state: ^[65536]u8) {}

main :: proc() {
    fmt.print("Found the bug!")
    foo_deinit(&foo)
}
simple saffron
#

Thank you!

deft salmon
#

Not sure if you'd prefer me to make an issue on git. I just thought I could share that the snippet to make testing easier

simple saffron
#

I think that crash is just because you are returning a huge array from a procedure.

#

And thus found an LLVM bug

deft salmon
#

yeah, that's because microui reserves all that space for its stacks

#

whats wierd is that you need to call init at global scope, and also deinit. otherwise there is no crash