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

Illumos part3 #3575

Merged
merged 1 commit into from May 12, 2024
Merged

Illumos part3 #3575

merged 1 commit into from May 12, 2024

Conversation

devnexen
Copy link
Contributor

@devnexen devnexen commented May 5, 2024

Fixes #3567


// 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
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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.^^

Copy link
Contributor Author

@devnexen devnexen May 6, 2024

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.

Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {

@RalfJung
Copy link
Member

RalfJung commented May 6, 2024

That CI failure is actually a legit bug in std, I think: rust-lang/rust#124787.

@devnexen
Copy link
Contributor Author

devnexen commented May 6, 2024

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"))?;
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

@RalfJung RalfJung added the S-blocked Status: blocked on something happening somewhere else label May 6, 2024
@bors
Copy link
Collaborator

bors commented May 6, 2024

☔ 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" => {
Copy link
Member

@RalfJung RalfJung May 12, 2024

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.

Copy link
Member

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.

@RalfJung
Copy link
Member

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.

@RalfJung
Copy link
Member

#3602 landed, so if you rebase again it should pick up your rustc PRs.

@devnexen devnexen force-pushed the illumos_part3 branch 2 times, most recently from 7083a45 to 84d965c Compare May 12, 2024 16:32
@devnexen devnexen marked this pull request as ready for review May 12, 2024 16:59
@devnexen
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-blocked Status: blocked on something happening somewhere else labels May 12, 2024
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member

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?

@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels May 12, 2024
@devnexen devnexen force-pushed the illumos_part3 branch 2 times, most recently from f02f5a1 to d2c2082 Compare May 12, 2024 18:26
fixing part of `miri test alloc/hashmap`.
@devnexen
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels May 12, 2024
@RalfJung
Copy link
Member

Looks good, thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented May 12, 2024

📌 Commit 20a0257 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 12, 2024

⌛ Testing commit 20a0257 with merge 8e36860...

@bors
Copy link
Collaborator

bors commented May 12, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 8e36860 to master...

@bors bors merged commit 8e36860 into rust-lang:master May 12, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illumos: make basic std facilities work
4 participants