fix: avoid the non-thread-safe strerror in lean_decode_io_error#14423
Merged
Conversation
This PR prevents possible corruption if two threads simultaneously call `lean_decode_io_error`.
Contributor
Author
|
changelog-compiler |
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
Kha
approved these changes
Jul 17, 2026
TwoFX
approved these changes
Jul 20, 2026
This was referenced Jul 20, 2026
JJYYY-JJY
pushed a commit
to JJYYY-JJY/lean4
that referenced
this pull request
Jul 20, 2026
…de_io_error` (leanprover#14423)" (leanprover#14463) This PR reverts leanprover#14423 until we can get the situation on Windows figured out.
JJYYY-JJY
pushed a commit
to JJYYY-JJY/lean4
that referenced
this pull request
Jul 22, 2026
…eanprover#14479) This PR prevents possible corruption if two threads simultaneously call `lean_decode_io_error`. It also changes the semantics of `osCode` in `IO.Error`, such that it emulates posix `errno` rather than forwarding uv error codes cast to unsigned integers. Recall that `strerror` is not thread-safe. This also removes the need to maintain two separate error lookups, but we do need to introduce a function that translates C runtime `errno` numbers to LibUV error codes. The function `uv_translate_sys_error` cannot be used since on Windows that one expects Windows system error codes, which are not the same thing. This is still a win because the translation function is much simpler than the error lookup. This PR is a second attempt at leanprover#14423. Zulip: [#lean4 > Signedness of IO.Error's osCode and libuv @ 💬](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Signedness.20of.20IO.2EError.27s.20osCode.20and.20libuv/near/611212153) Co-authored-by: Eric Wieser <efw@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR prevents possible corruption if two threads simultaneously call
lean_decode_io_error. It also changes the semantics ofosCodeinIO.Error, such that it emulates posixerrnorather than forwarding uv error codes cast to unsigned integers.Recall that
strerroris not thread-safe.This also removes the need to maintain two separate error lookups.
Zulip: #lean4 > Signedness of IO.Error's osCode and libuv @ 💬