Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign.C.Error.errnoToIOError should use strerror_r, not strerror #249

Closed
bgamari opened this issue Jan 26, 2024 · 14 comments
Closed

Foreign.C.Error.errnoToIOError should use strerror_r, not strerror #249

bgamari opened this issue Jan 26, 2024 · 14 comments
Labels
approved Approved by CLC vote

Comments

@bgamari
Copy link

bgamari commented Jan 26, 2024

strerror is not in general thread-safe and therefore cannot be reliably used in Haskell programs. POSIX.1-2001 provides strerror_r, which is reentrant while providing similar semantics. On Windows we must rather use stderror_s. Foreign.C.Error.errnoToIOError should use these not strerror.

See GHC #24344.

@Bodigrim
Copy link
Collaborator

The MR is at https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11984. Once CI is green, I intend to trigger a vote so that we have a chance to fix it in time for GHC 9.10.

@bgamari
Copy link
Author

bgamari commented Jan 31, 2024

It would be appreciated if we could bring this to a vote as I don't imagine that the approach is going to fundamentally change at this point.

@Bodigrim
Copy link
Collaborator

@bgamari I made an exception for the series of exception backtraces proposals, but in general we strive to vote on a finished MR so that there are less surprises afterwards. Please ping me once CI gets green.

@bgamari
Copy link
Author

bgamari commented Feb 1, 2024

The MR is now passing.

@tomjaguarpaw
Copy link
Member

+1


This seems very sensible

@phadej
Copy link

phadej commented Feb 1, 2024

Looking at the change I wonder whether this is exactly a change one should not need to ask CLC about?

The readme of this repository says:

The ownership of base belongs to GHC developers, and they can maintain it freely without CLC involvement as long as changes are invisible to clients.

@Bodigrim
Copy link
Collaborator

Bodigrim commented Feb 1, 2024

Dear CLC members, let's vote on the proposal to implement Foreign.C.Error.errnoToIOError via strerror_r instead of strerror, which provides for better thread safety. The MR is at https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11984. This is not a breaking change.

@hasufell @mixphix @velveteer @angerman @parsonsmatt


+1 from me.

@velveteer
Copy link
Contributor

+1

@bgamari
Copy link
Author

bgamari commented Feb 2, 2024

Looking at the change I wonder whether this is exactly a change one should not need to ask CLC about?

That was my feeling as well; however, out of deference to the committee I asked and @Bodigrim advised to open a proposal.

@mixphix
Copy link
Collaborator

mixphix commented Feb 2, 2024

+1

@phadej
Copy link

phadej commented Feb 3, 2024

Looking at the change I wonder whether this is exactly a change one should not need to ask CLC about?

That was my feeling as well; however, out of deference to the committee I asked and @Bodigrim advised to open a proposal.

This sets a precedence that virtually any change to base have to go through CLC.

In particular, I don't think that

The ownership of base belongs to GHC developers

is true. There cannot be responsibility without power.

@Bodigrim
Copy link
Collaborator

Bodigrim commented Feb 3, 2024

The change affects visible behavior of base, ergo falls under CLC purview.

If there is an interest in a meta discussion, please open a separate issue.

@hasufell
Copy link
Member

hasufell commented Feb 3, 2024

+1

@Bodigrim
Copy link
Collaborator

Bodigrim commented Feb 3, 2024

Thanks all, that's enough votes to approve.

@Bodigrim Bodigrim closed this as completed Feb 3, 2024
@Bodigrim Bodigrim added the approved Approved by CLC vote label Feb 3, 2024
hubot pushed a commit to ghc/ghc that referenced this issue Feb 15, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Feb 16, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Feb 18, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Feb 19, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Feb 19, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Mar 8, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Mar 8, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Mar 8, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
hubot pushed a commit to ghc/ghc that referenced this issue Mar 8, 2024
As noted by #24344, `strerror` is not necessarily thread-safe.
Thankfully, POSIX.1-2001 has long offered `strerror_r`, which is
safe to use.

Fixes #24344.

CLC discussion: haskell/core-libraries-committee#249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved by CLC vote
Projects
None yet
Development

No branches or pull requests

7 participants