Closed elcritch closed 1 year ago
While digging into https://github.com/codex-storage/questionable/issues/41 I noticed that binderror uses a global to store the last error state:
binderror
https://github.com/codex-storage/questionable/blob/e56cf86c4a089c78a1b7c3005f13343bfbbe3b48/questionable/private/binderror.nim#L4C10-L4C10
It should probably be made into var errorVariable: ptr ref CatchableError.
var errorVariable: ptr ref CatchableError
If it's not a threadvar issues might arise when used with multiple threads. I haven't worked through the precise logic, but some sequence similar to:
without
errorVariable
Probably not all too likely and shouldn't cause a false error case, just report the wrong error. That'd still be annoying.
Good find, thanks! I was able to reproduce this in a test and adding {.threadvar.} indeed fixes the problem: #46
{.threadvar.}
While digging into https://github.com/codex-storage/questionable/issues/41 I noticed that
binderror
uses a global to store the last error state:https://github.com/codex-storage/questionable/blob/e56cf86c4a089c78a1b7c3005f13343bfbbe3b48/questionable/private/binderror.nim#L4C10-L4C10
It should probably be made into
var errorVariable: ptr ref CatchableError
.If it's not a threadvar issues might arise when used with multiple threads. I haven't worked through the precise logic, but some sequence similar to:
without
clauseerrorVariable
to store an error ptrerrorVariable
errorVariable
and gets the error meant for thread2Probably not all too likely and shouldn't cause a false error case, just report the wrong error. That'd still be annoying.