Release ignored error contexts #21

Merged
andrew merged 3 commits from 14 into main 2026-08-04 11:28:30 -04:00
Collaborator

Closes #14.

Summary

  • release the error context after IGNORE() logs it
  • retain a per-thread static snapshot of the ignored error for debugging
  • repair the copied stack-trace cursor so the snapshot remains self-contained
  • exercise more ignored failures than the pool has slots
  • update threaded coverage and lifecycle documentation

Tests

  • cmake -S . -B build
  • cmake --build build
  • ctest --test-dir build --output-on-failure (36/36)
  • scripts/thread_test.sh (36/36 under ThreadSanitizer)
  • cmake -S . -B build/none -DAKERR_THREADS=none
  • ctest --test-dir build/none --output-on-failure (32/32)
Closes #14. ## Summary - release the error context after IGNORE() logs it - retain a per-thread static snapshot of the ignored error for debugging - repair the copied stack-trace cursor so the snapshot remains self-contained - exercise more ignored failures than the pool has slots - update threaded coverage and lifecycle documentation ## Tests - cmake -S . -B build - cmake --build build - ctest --test-dir build --output-on-failure (36/36) - scripts/thread_test.sh (36/36 under ThreadSanitizer) - cmake -S . -B build/none -DAKERR_THREADS=none - ctest --test-dir build/none --output-on-failure (32/32)
logikoma added 1 commit 2026-08-03 12:57:11 -04:00
Release ignored error contexts
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m52s
libakerror CI Build / coverage (push) Successful in 2m48s
libakerror CI Build / mutation_test (push) Successful in 44m14s
eec5726d91
logikoma force-pushed 14 from eec5726d91 to 4fe7571329 2026-08-03 13:46:44 -04:00 Compare
andrew reviewed 2026-08-03 13:59:34 -04:00
andrew reviewed 2026-08-03 14:01:28 -04:00
@@ -105,2 +100,3 @@
/* IGNORE's scratch pointer is thread-local while logging and cleared after
* release. Concurrent ignored errors must all return their pool slots. */
IGNORE(ignorable(arg));
AKERR_TCHECK(arg, __akerr_last_ignored != NULL);
Owner

IGNORE() retained a reference to the last ignored error on purpose, so that subsequent errors that may be related could reference it. Instead of completely abandoning it (and the pattern that allows it), why not turn __akerr_last_ignored into a static variable, IGNORE() does a memcpy() into it from the exception being ignored, then releases the exception? That seems like it would give us the best of both worlds.

IGNORE() retained a reference to the last ignored error on purpose, so that subsequent errors that may be related could reference it. Instead of completely abandoning it (and the pattern that allows it), why not turn __akerr_last_ignored into a static variable, IGNORE() does a `memcpy()` into it from the exception being ignored, then releases the exception? That seems like it would give us the best of both worlds.
Owner

IGNORE() retained a reference to the last ignored error on purpose, so that subsequent errors that may be related could reference it. Instead of completely abandoning it (and the pattern that allows it), why not turn __akerr_last_ignored into a static variable, IGNORE() does a memcpy() into it from the exception being ignored, then releases the exception? That seems like it would give us the best of both worlds.

@logikoma ^ implement this

> IGNORE() retained a reference to the last ignored error on purpose, so that subsequent errors that may be related could reference it. Instead of completely abandoning it (and the pattern that allows it), why not turn __akerr_last_ignored into a static variable, IGNORE() does a `memcpy()` into it from the exception being ignored, then releases the exception? That seems like it would give us the best of both worlds. @logikoma ^ implement this
andrew marked this conversation as resolved
logikoma requested review from andrew 2026-08-03 18:22:29 -04:00
logikoma added 1 commit 2026-08-04 10:45:52 -04:00
Preserve ignored error snapshots
Some checks failed
libakerror CI Build / coverage (push) Successful in 3m39s
libakerror CI Build / cmake_build (push) Successful in 6m3s
libakerror CI Build / mutation_test (push) Has been cancelled
55090d2419
Author
Collaborator

Implemented the requested review change. IGNORE() now copies the error into a per-thread static snapshot with a repaired stack-trace cursor, logs that snapshot, and releases the original pool context. Tests verify the snapshot survives slot reuse in both single-threaded and threaded runs. Full CTest, ThreadSanitizer, and no-thread CTest pass.

Implemented the requested review change. IGNORE() now copies the error into a per-thread static snapshot with a repaired stack-trace cursor, logs that snapshot, and releases the original pool context. Tests verify the snapshot survives slot reuse in both single-threaded and threaded runs. Full CTest, ThreadSanitizer, and no-thread CTest pass.
andrew reviewed 2026-08-04 10:58:14 -04:00
@@ -441,0 +438,4 @@
do { \
akerr_ErrorContext *__akerr_ignored = __stmt; \
if ( __akerr_ignored != NULL ) { \
memcpy(&__akerr_last_ignored, __akerr_ignored, \
Owner

@logikoma the __akerr_last_ignored variable is only really useful to users of the public facing API, so I'm not sure it makes sense to prefix it with __ as part of the private API. Let's remove the __ prefix on this variable and make it public.

@logikoma the `__akerr_last_ignored` variable is only really useful to users of the public facing API, so I'm not sure it makes sense to prefix it with `__` as part of the private API. Let's remove the `__` prefix on this variable and make it public.
logikoma marked this conversation as resolved
logikoma added 1 commit 2026-08-04 11:25:31 -04:00
Expose ignored error snapshot
All checks were successful
libakerror CI Build / coverage (push) Successful in 3m18s
libakerror CI Build / cmake_build (push) Successful in 10m11s
libakerror CI Build / mutation_test (push) Successful in 45m33s
5a269ea01b
Co-Authored-By: Andrew Kesterson <andrew@aklabs.net>
Author
Collaborator

Implemented in 5a269ea. IGNORE() now copies the ignored context into the per-thread static snapshot, repairs the copied stack-trace cursor, logs it, and releases the pool context. The public snapshot is now named akerr_last_ignored. Normal tests pass 36/36; AKERR_THREADS=none passes 32/32.

Implemented in 5a269ea. IGNORE() now copies the ignored context into the per-thread static snapshot, repairs the copied stack-trace cursor, logs it, and releases the pool context. The public snapshot is now named akerr_last_ignored. Normal tests pass 36/36; AKERR_THREADS=none passes 32/32.
andrew merged commit c82f5fe695 into main 2026-08-04 11:28:30 -04:00
Sign in to join this conversation.