Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: register GC callbacks inside GC.init (#15278)
Running the std specs would immediately hang with the `master` branch of the GC, waiting on `GC.lock_write`: the GC is trying to collect while Crystal is initializing constants and class variables (`__crystal_main`) and it would lock the rwlock for write twice, never unlocking it, before the start callback was registered, but not the before collect callback (oops). This patch: 1. Registers the GC callbacks right in the GC.init method; this makes sure all callbacks are registered before we start running any Crystal code. 2. Initializes the rwlock inside the GC.init method; this avoids a lazy initializer and makes sure the memory is properly initialized ASAP.
- Loading branch information