Hi there,
The application compiles fine, but it fails when I try to run it.
System info:
- MBP 2026 with M5 processor
- Crystal installed through MacPorts
When I compiled the application with -Dwithout_mt I see this error.
Unhandled exception: kevent: No such file or directory (RuntimeError)
from /opt/local/share/crystal/src/errno.cr:48 in 'Crystal::EventLoop::Kqueue#initialize<Int32>:Nil'
from /opt/local/share/crystal/src/gc/boehm.cr:193:7 in 'Thread#scheduler:Crystal::Scheduler'
from /opt/local/share/crystal/src/crystal/scheduler.cr:31:5 in 'unbuffered_write'
from /opt/local/share/crystal/src/crystal/once.cr:124:1 in 'main'
from /opt/local/share/crystal/src/crystal/system/unix/main.cr:10:3 in 'main'
If I compiled the application without -Dwithout_mt, the error changes:
Unhandled exception: Thread#execution_context cannot be nil (NilAssertionError)
from /opt/local/share/crystal/src/crystal/event_loop.cr:35 in 'event_loop'
from /opt/local/share/crystal/src/crystal/system/file_descriptor.cr:44:5 in 'unbuffered_write'
from /opt/local/share/crystal/src/crystal/once.cr:124:1 in 'main'
from /opt/local/share/crystal/src/crystal/system/unix/main.cr:10:3 in 'main'
Same program compiled with previous versions ran fine.
I suspect the MacPorts installation is broken.
It’s not just MacPorts. I get the exact same errors using the compiler I compiled myself (using the Homebrew-installed compiler) from the GitHub repo.
Interestingly, if I use asdf to install the Crystal compiler, I can compile the compiler from GitHub and run programs compiled with --release just fine, but not after compiling the compiler with the Homebrew-installed compiler. I don’t know what the difference is.
I have had similar issues a few times, but not deterministically. @MarioAriasC Are yours happening 100% of the time?
Mine have been on other architectures: linux/amd64 and linux/arm64 – not MacPorts – and I made a small additional comment here: BUG: Fiber::ExecutionContext::Monitor#every crashed(Crystal 1.21.0) · Issue #17212 · crystal-lang/crystal · GitHub but @ysbaddaden said it was fixed by Fix: support bare threads in crystal/once by ysbaddaden · Pull Request #17228 · crystal-lang/crystal · GitHub .
As far as I can tell, the fix from PR 17228 was not included in the v1.21.1 tagged release:
and the PR is tagged for the 1.22.0 milestone.
It happens deterministically, but I only have an M5 now to test.
I may be able to get a Linux with AMD Ryzen working this week.
I also confirmed that it works without the --release flag
Interesting. It’d be interesting if you could try it with the latest nightly build Nightly Builds - The Crystal Programming Language , and there are two options for macOS there. I suspect that the existing PR 17228 merged into master fixes the issue for you! 