-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
637 Solaris getrandom() support breaks illumos #730
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stumbled upon this while investigating rust-lang/miri#3924. In this code, the return type is different between Illumos and Solaris. However, in today's libc, the return type is the same for both OSes. (This was added in rust-lang/libc#2236.)
Do you remember where you got the different return type from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was like this since getrandom v0.1 days: https://docs.rs/crate/getrandom/0.1.0/source/src/solaris_illumos.rs#28-31
We probably just copied what
std
done at the time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current version of
getrandom
we uselibc::getrandom
, so it should no longer be an issue with up-to-date dependencies.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah getrandom is older than this? Okay.
Yeah, I am just trying to figure out where the other return type comes from and which one is correct...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rand_os
is an older crate. It was eventually deprecated in favor ofgetrandom
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other traces pointing at Solaris having a different return type, see rust-lang/miri#3924:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the version pre-change.
The
getrandom()
function was something that was added to both OSes after both forked. There is no cross-pollination between the two projects. Oracle does their own thing and the only notice you get about anything is when a release comes out. illumos does what we feel is best for us -- while we strive to not break existing stuff, when adding new interfaces, while compatibility with Solaris may be a factor, it is far from the only (or most important) factor.In this case,
getrandom()
was added after illumos forked from Solaris. I'm not sure which one got it first, but the illumos version was modeled after FreeBSD. It appears that Oracle changed the function signature in Solaris 11.4 so it was the same as the illumos and FreeBSD version (you can look at the section 2 man pages of Solaris 11.3 and Solaris 11.4).The use of dlsym was to better support the existing
is_getrandom_available
test. Issuing unsupported syscalls on Solaris and illumos systems (as noted in the comments) generates a SYSSIG signal which is usually unhandled by a program (and thus usually crashes it). Checking for the libc function is less likely to cause problems.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why you are even talking about Illumos. My question is entirely and exclusively about Solaris. For the purpose of this discussion, I am treating the two as completely independent OSes.
EDIT: I probably wasn't sufficiently clear in the original question here. That's why I linked to rust-lang/miri#3924 for context. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, the question is, what is the return type for
getrandom
on Solaris? This PR made itc_int
. But today in the libc crate, it isssize_t
. Who is right? Or did Solaris change the return type of this function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's our best running theory. It seems very strange to me that one can just change such a function signature but maybe that works for Oracle for some reason?
That hypothesis explains basically everything, except for https://www.gnu.org/software/gnulib/manual/html_node/getrandom.html which says