odin-lang / Odin

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

Infinite loop when compiling procedure with weird parapoly signature #3759

Open dholmin opened 5 months ago

dholmin commented 5 months ago

Context

Odin:    dev-2024-06:02f11dfde
OS:      macOS Mojave 10.14.6 (build: 18G2022, kernel: 18.7.0)
CPU:     Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
RAM:     8192 MiB
Backend: LLVM 13.0.1

Also happens on my M1 Pro MacBook.

Failure Information

odin build . doesn't terminate when compiling the following:

binary_search :: proc(slice: $T/[]$E, value: E, projection: proc(v: E) -> $K = proc(v2: E) -> K { return v2 }) -> int
{
    return 0
}

It happened when I added the parapoly proc default argument, but I haven't had time to boil it down further.

Kelimion commented 5 months ago

Replicated. It's stuck at check procedure bodies.

W:\Odin\bug>odin build bug.odin -file -show-debug-messages
<snip>
[DEBUG] [Section] export entities - post
[DEBUG] [Section] add entities from packages
[DEBUG] [Section] check all global entities
[DEBUG] [Section] init preload
[DEBUG] [Section] add global untyped expression to queue
[DEBUG] [Section] check procedure bodies
Feoramund commented 5 months ago

I'm looking at this at the moment. Be careful if you let this run too long without sending a pause signal. It's allocating infinitely many procedures to check and consumed several gigabytes of memory for me.