Skip to content

Some garbage collector fixes - #5558

Open
digitalentity wants to merge 3 commits into
tinygo-org:devfrom
helvionics:de_gc_fixes
Open

Some garbage collector fixes#5558
digitalentity wants to merge 3 commits into
tinygo-org:devfrom
helvionics:de_gc_fixes

Conversation

@digitalentity

Copy link
Copy Markdown
Contributor

Mostly correctness fixes, but the issue with cores scheduler may cause unexpected crashes during GC mark phase.

  • fixed incorrect previous size calculation in block realloc, causing potential data loss on growing reallocs.
  • fixed incorrect comparison, causing a premature OOM on the leaking alloc (rather improbable though).
  • correctly pause all cores during the GC mark phase, preventing a data race.

Using blocksPerStateByte instead of bytesPerBlock caused the old size to be underestimated for multi-block allocations, leading to data truncation on growing reallocations.
Change heap-end comparison to > to prevent spurious OOM when heapptr exactly matches heapEnd. Add overflow check to prevent heap wrapping.
In gcMarkReachable, busy-wait for other cores to enter the interrupt handler and pause before scanning the GC core's stack or globals. Prevents data race where a running core relocates heap references to globals during mark phase.
@digitalentity
digitalentity marked this pull request as ready for review July 26, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant