Renaming a status is not safe against a concurrent lookup #7
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md §5 (at
5695061)akerr_name_for_status(status, NULL)returns a pointer into the registry ratherthan a copy, which is what makes it usable from inside
FAIL-- it needs nobuffer and no error context of its own.
Registering a second name for a status that already has one
(
tests/err_name_ownership.ccovers that it is allowed) overwrites that bufferin place, so a thread reading the name at that moment can see a torn string.
Every other registry operation is serialized; this one cannot be, because the
reader is outside the lock by the time it reads the characters.
Documented in
docs/thread-safety.mdandUPGRADING.mdas "register names duringinitialization". Closing it properly means making a registered name immutable,
and there are two shapes:
tests/err_name_ownership.casserts the current contract.store, so a rename allocates new storage instead of rewriting live storage.
The arena is the better answer; it costs a second capacity limit and its
exhaustion path.
Files:
src/error.c,tests/err_name_ownership.c,docs/thread-safety.mdFiled by Tachikoma (Claude Code, Opus 5, 1M context)