odin-lang / Odin

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

Segfault when reporting multiple (>36) errors on more than one file. #3169

Closed MineBill closed 2 months ago

MineBill commented 6 months ago

Context

When running odin check <dir> and there are way more errors than the maximum error collector count (36), there is a chance to get a segfault.

I initially discovered this when working on my project with the odin language server. ols will run odin check when the file is saved to report any errors. I've configured ols to run odin check with -vet-semicolon. The problem is, a 3rd party package i use is full of them, so a huge amount of errors get reported. But because odin segfaults, ols will fail to properly capture its output and will not report them.

Expected Behavior

Odin should not segfault once it has reached the maximum amount of reported errors and instead exit normally.

Current Behavior

Assuming a directory with more than two files and enough errors (>36), a segfault might happen. It should be noted that the more errors there are the greater the chance for the segfault.

Failure Information (for bugs)

Attaching a debugger shows that the segfault happens after https://github.com/odin-lang/Odin/blob/4e300ff90a0d4b9d706a21a9fc155aa1536d934c/src/error.cpp#L438

Steps to Reproduce

// name it proc2 for the second file proc1 :: proc() { = 1; ... // Repeat many times, >50 should be enough. = 1; }


- 2 Alternatively, i've attached these files to this bug report.
[bug_report.zip](https://github.com/odin-lang/Odin/files/14154499/bug_report.zip)
- 3 Run `odin check <dir> -no-entry-point -vet-semicolon` multiple times, until a segfault happens.
gingerBill commented 4 months ago

This should not be a problem any more with the new error reporting system. Can you please test this on master.