Skip to content

Preserve fetch error text; synchronize the VFS last-error string - #19

Merged
mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/f4-c5-fixes
Oct 24, 2026
Merged

mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/f4-c5-fixes

Conversation

@Wid-L-Hacker

Copy link
Copy Markdown
Contributor

F4: Read1Page called job->Renew(), which clears job->errmsg, before constructing an exception from job->errmsg. The exception reaching Read() therefore had an empty message. Capture the message before Renew().

C5: Open and FullPathname wrote the shared last_error_ string without synchronization; GetLastError read it unlocked. ThreadSanitizer caught concurrent writes during failed opens. Route writes through SetLastError(), copy under the mutex in GetLastError(), and log local strings. Existing error strings and explicit return codes are unchanged.

Verified: C5 reports disappeared in TSan A/B stress runs; successful reads matched expected data byte for byte. Full Catch2 suite: 36,338 assertions passed.

F4: Read1Page called job->Renew() - which clears job->errmsg - before
throwing an exception built from job->errmsg, so read failures reached
callers with an empty message. Capture the message before Renew().

C5: the VFS object's last_error_ std::string was written by Open and
FullPathname from any thread with no synchronization (ThreadSanitizer
caught write-vs-write through the string internals during a concurrent
failed-open storm). Guard all accesses with a mutex via a SetLastError()
helper; GetLastError() copies under the lock. No error text or result
codes change.

Verified: TSan A/B on the concurrency stress drivers (C5 traces gone,
reads byte-exact); full Catch2 suite passes (36,338 assertions).
@mlin
mlin merged commit 4e6708d into mlin:main Oct 24, 2026
5 checks passed
@mlin
mlin deleted the conrad/f4-c5-fixes branch October 24, 2026 19:22
Wid-L-Hacker added a commit to Wid-L-Hacker/sqlite_zstd_vfs that referenced this pull request Oct 25, 2026
Brings the web fixes merged since 16072b1 into this build: F5 +
ThreadPool C1/C2 (mlin#17), F6 Close self-delete (mlin#18), F7 Content-Range
validation (mlin#19), C6 last_error_ synchronization (mlin#20).
mlin pushed a commit that referenced this pull request Oct 25, 2026
Brings the web fixes merged since 16072b1 into this build: F5 +
ThreadPool C1/C2 (#17), F6 Close self-delete (#18), F7 Content-Range
validation (#19), C6 last_error_ synchronization (#20).
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