Skip to content

Fix thread safety issues in pty and termios tests #691

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

Merged
merged 1 commit into from
Jul 21, 2017

Conversation

asomers
Copy link
Member

@asomers asomers commented Jul 20, 2017

ptsname(3) returns a pointer to a global variable, so it isn't
thread-safe. Protect it with a mutex.

ptsname(3) returns a pointer to a global variable, so it isn't
thread-safe.  Protect it with a mutex.
@Susurrus
Copy link
Contributor

Have you seen this be an actual issue? My understanding is that this is just like the errno strings, where the strings are static in global memory, but they never change, so you should be able to pass around pointers to them willy-nilly.

@asomers
Copy link
Member Author

asomers commented Jul 20, 2017

Yep. If I run the tests with --test-threads=8, I get failures due to ptsname within seconds. This is the very reason that ptsname_r exists. It's like the difference between strerror and strerror_r

@Susurrus
Copy link
Contributor

Hmm, I've never seen those fail locally, but this does seem like the right fix.

LGTM

bors r+

@asomers
Copy link
Member Author

asomers commented Jul 21, 2017

Since bors is stuck, I'm going to manually merge

bors r-

@asomers asomers merged commit 26c35c0 into nix-rust:master Jul 21, 2017
@asomers asomers deleted the ptsname branch July 21, 2017 04:56
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