odin-lang / Odin

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

`or_continue` produces flaky compilation results: sometimes a compile error, sometimes `Segmentation fault (core dumped)` #3794

Closed tadeohepperle closed 1 week ago

tadeohepperle commented 1 week ago

Context

Odin Version and OS:

    Odin:    dev-2024-06:f1779c85d
    OS:      Manjaro Linux, Linux 6.1.80-1-MANJARO
    CPU:     12th Gen Intel(R) Core(TM) i7-1260P
    RAM:     31806 MiB
    Backend: LLVM 14.0.6

Expected Behavior

Compiler should give the compile error consistenly and never Segmentation fault (core dumped).

Current Behavior & Steps to Reproduce

When Running

package odincrash
import "core:fmt"
import "core:os"
main :: proc() {
    files := [?]string{"i.txt", "j.txt"}
    for &f in files {
        stat := os.stat(f, allocator = context.temp_allocator) or_continue
        fmt.println(stat)
    }
}

Half of the time I get

/home/tadeo/Desktop/test/odincrash/main.odin(10:11) Error: 'or_continue' expects an "optional ok" like value, or an n-valued expression where the last value is either a boolean or can be compared against 'nil', got Errno 
        stat := os.stat(f, allocator = context.temp_allocator) or_contin ... 
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 

Half of the time I just get Segmentation fault (core dumped) from the compiler.

Feoramund commented 1 week ago

I can confirm this is happening.