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

This commit is contained in:
2026-08-04 10:44:46 -04:00
parent 4fe7571329
commit 55090d2419
5 changed files with 51 additions and 23 deletions

View File

@@ -90,6 +90,9 @@ static void one_checkout(akerr_ThreadArg *arg)
static void *pool_body(void *raw)
{
akerr_ThreadArg *arg = raw;
char expected[64];
snprintf(expected, sizeof(expected), "ignored by thread %d", arg->id);
pthread_barrier_wait(arg->barrier);
for ( int i = 0; i < ITERATIONS; i++ ) {
@@ -97,10 +100,21 @@ static void *pool_body(void *raw)
one_checkout(arg);
}
/* IGNORE's scratch pointer is thread-local while logging and cleared after
/* IGNORE's snapshot is thread-local while logging and remains valid after
* release. Concurrent ignored errors must all return their pool slots. */
IGNORE(ignorable(arg));
AKERR_TCHECK(arg, __akerr_last_ignored == NULL);
AKERR_TCHECK(arg, __akerr_last_ignored.status == AKERR_IO);
AKERR_TCHECK(arg, strcmp(__akerr_last_ignored.message, expected) == 0);
/* Reuse a slot after IGNORE and prove that the copied snapshot did not
* become an alias for the newly acquired context. */
akerr_ErrorContext *reused = akerr_next_error();
AKERR_TCHECK(arg, reused != NULL);
if ( reused != NULL ) {
RELEASE_ERROR(reused);
}
AKERR_TCHECK(arg, __akerr_last_ignored.status == AKERR_IO);
AKERR_TCHECK(arg, strcmp(__akerr_last_ignored.message, expected) == 0);
return NULL;
}