odin-lang / Odin

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

Setup `context.random_generator` in test runner #3767

Closed Feoramund closed 2 weeks ago

Feoramund commented 2 weeks ago

I've set it up so the test runner initiates the random generator now, so tests don't have to.

Feoramund commented 2 weeks ago

There's something to this Buggy_Struct test failure. It appeared on my fork's CI as well. I thought it initially to be a quirk of the GitHub process after checking for any rand procs in it, but now I'm not so sure.

Feoramund commented 2 weeks ago

I have a tentative fix for this, but I don't know why it works. I've been borrowing GitHub's CI to experiment with atomic changes on a separate branch to see what makes this bug arise, since I do not have access to a Windows machine.

The call to runtime.default_random_generator(&random_generator_state) is somehow causing this, because if I construct the generator in-place, Windows passes. I was also able to get it to pass by moving the RNG setup before the call to free_all.

Non-exhaustive list of other attempts at debugging this:

I'm baffled as to why a contextless proc that merely returns a struct would somehow cause a misread failure in rtti_test. The misread is very consistent too. It's always c on the l_buggy Buggy_Struct that gets seemingly random data.

It's fixed now, at least. I'm quite curious why it was happening and wish I could attach a debugger to the Windows executable.