Skip to content

fix(example): fix mem step-2-gc shutdown abort (#383) - #386

Merged
gg582 merged 2 commits into
c4punks:devfrom
Bhumika-1432006:fix/383-mem-step2-gc-shutdown
Oct 17, 2026
Merged

gg582 merged 2 commits into
c4punks:devfrom
Bhumika-1432006:fix/383-mem-step2-gc-shutdown

Conversation

@Bhumika-1432006

Copy link
Copy Markdown
Contributor

example/mem/step-2-gc/main.c crashes on every run at cwist_gc_shutdown() because cwist_alloc()-allocated pointers are passed to cwist_reg_ptr_sized(). At shutdown, ttak_epoch_gc_destroy() runs header validation over the registered pointers. cwist_alloc() does not produce TTAK-headered memory, so the validation aborts with the fatal message reported in issue #383.

What this changes: main.c is rewritten to use cwist_ebr_alloc() + cwist_ebr_free() + cwist_gc_pipeline_tick() -- the correct paired pattern for epoch-based deferred release. cwist_gc_t is kept in the example to demonstrate cwist_gc_auto_rotate() and cwist_gc_shutdown() on a context with no registered pointers, which shuts down cleanly.

How it was verified: the original main.c aborts at the cwist_gc_shutdown() call, confirmed against the repro in issue #383. The rewritten version exits at "Done" with status 0.

What it does not do: does not change the cwist_reg_ptr or cwist_gc_shutdown implementation; the library-side fix is a separate concern.

Bhumika-1432006 and others added 2 commits October 16, 2026 20:33
cwist_alloc() does not produce TTAK-headered memory, so passing its output
to cwist_reg_ptr_sized() and then calling cwist_gc_shutdown() (which runs
ttak_epoch_gc_destroy) triggers TTAK header validation and aborts with
"TTAK Memory Corruption detected (Header corrupted)".

The correct paired pattern for deferred, epoch-safe release is
cwist_ebr_alloc() + cwist_ebr_free() + cwist_gc_pipeline_tick(), which
does not pass ownership to ttak_epoch_gc_destroy. The example is rewritten
to use that pattern.

cwist_gc_t is kept in the example to demonstrate cwist_gc_auto_rotate()
and cwist_gc_shutdown() on a context with no registered pointers, which
shuts down cleanly.

Verified: the original main.c aborts at cwist_gc_shutdown(); the rewritten
version exits at "Done" with status 0.
@gg582
gg582 merged commit 85dcad2 into c4punks:dev Oct 17, 2026
24 checks passed
gg582 added a commit that referenced this pull request Oct 17, 2026
cwist_alloc() does not produce TTAK-headered memory, so passing its output
to cwist_reg_ptr_sized() and then calling cwist_gc_shutdown() (which runs
ttak_epoch_gc_destroy) triggers TTAK header validation and aborts with
"TTAK Memory Corruption detected (Header corrupted)".

The correct paired pattern for deferred, epoch-safe release is
cwist_ebr_alloc() + cwist_ebr_free() + cwist_gc_pipeline_tick(), which
does not pass ownership to ttak_epoch_gc_destroy. The example is rewritten
to use that pattern.

cwist_gc_t is kept in the example to demonstrate cwist_gc_auto_rotate()
and cwist_gc_shutdown() on a context with no registered pointers, which
shuts down cleanly.

Verified: the original main.c aborts at cwist_gc_shutdown(); the rewritten
version exits at "Done" with status 0.

Co-authored-by: 이윤진(Lee Yunjin) <168180007+gg582@users.noreply.github.com>
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.

2 participants