-
Notifications
You must be signed in to change notification settings - Fork 349
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
Illumos part3 #3575
Illumos part3 #3575
Conversation
|
||
// memalign requires the alignment to be a power of 2 | ||
// and to be, at least, of word size. | ||
// http://docs.oracle.com/cd/E88353_01/html/E37743/memalign-3c.html |
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.
This URL shows an error 404 for me.
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 found it at https://docs.oracle.com/cd/E88353_01/html/E37843/memalign-3c.html.
It doesn't say what happens when the alignment is violated though -- is it UB or a safe error?
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 no it does say something:
The memalign() function may also fail if:
EINVAL
The value of the alignment parameter is not a power of two multiple of sizeof(void *), or the size parameter is zero, or the combination of the two would lead to an integer overflow.
But how is the error returned...?
This is where it'd probably be good to experiment with an actual Solaris/Illumos system and see what happens on a bad alignment.^^
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 just tried on my illumos instance, it returns null and emits EINVAL. Same with 0 even if alignment 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.
What does "emit" mean"?
In this document and in man memalign
on my system it says that memalign
returns NULL and sets errno on error.
// memalign requires the alignment to be a power of 2 | ||
// and to be, at least, of word size. | ||
// http://docs.oracle.com/cd/E88353_01/html/E37743/memalign-3c.html | ||
if !align.is_power_of_two() || align < this.pointer_size().bytes() || size == 0 { |
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.
if !align.is_power_of_two() || align < this.pointer_size().bytes() || size == 0 { | |
// The docs also guarantee a null pointer is returned when the size is 0. | |
if !align.is_power_of_two() || align < this.pointer_size().bytes() || size == 0 { |
That CI failure is actually a legit bug in std, I think: rust-lang/rust#124787. |
alright .. same will wait the getrandom part being merged to pick up this PR. |
// and a null pointer is returned. | ||
// https://docs.oracle.com/cd/E88353_01/html/E37843/memalign-3c.html | ||
if !align.is_power_of_two() || align < this.pointer_size().bytes() || size == 0 { | ||
this.set_last_error(this.eval_libc("EINVAL"))?; |
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 think size 0 should lead to EINVAL.
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 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, it is listed in the error conditions below: "or the size parameter is zero". But it's not listed above. Wow that's bad documentation.^^
Please point this out in the comments.
☔ The latest upstream changes (presumably #3579) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -18,6 +19,30 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { | |||
) -> InterpResult<'tcx, EmulateItemResult> { | |||
let this = self.eval_context_mut(); | |||
match link_name.as_str() { | |||
// Allocation | |||
"memalign" => { |
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.
With rust-lang/rust#124798, memalign
will not be called on Solarish any more.
You can still add it here if you want, but then you should also add a test that calls this function (directly via libc
). Alternatively, remove it from this PR.
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.
This comment is not resolved yet: you're adding a new shim that's entirely untested. That's not going to fly.
CI fails because rust-lang/rust#124766 isn't picked up automatically; I have to do a rustc-pull for that. But let's wait for rust-lang/rust#124798 to land first, so we can do it all at once. |
#3602 landed, so if you rebase again it should pick up your rustc PRs. |
7083a45
to
84d965c
Compare
@rustbot ready |
ci/ci.sh
Outdated
@@ -148,8 +148,8 @@ case $HOST_TARGET in | |||
BASIC="$VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures | |||
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus | |||
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus | |||
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random | |||
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random | |||
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random alloc hashmap |
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.
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random alloc hashmap | |
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random |
same for solaris
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.
This test isn't actually run by this PR, is it? same for the environ
change. Did you mean to add env
to the CI filters?
@rustbot author |
f02f5a1
to
d2c2082
Compare
fixing part of `miri test alloc/hashmap`.
@rustbot ready |
Looks good, thanks! |
☀️ Test successful - checks-actions |
Fixes #3567