Skip to content

Conversation

leso-kn
Copy link

@leso-kn leso-kn commented Feb 17, 2024

Motivation

This PR addresses the issue described in #6355, it fixes a segmentation fault in park_timeout() on riscv64.

Solution

Following the rust documentation on black_box in std::hint it's possible to instruct the compiler to prevent optimizing a specific call.

if let Some(mut driver) = self.inner.shared.driver.try_lock() {

Wrapping try_lock() with black_box() in park.rs:74 causes the compiler to block optimizations for the call and prevents omission of the call.

Tested on Alpine Linux edge (riscv64)

See https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/50419 for details.

@github-actions github-actions bot added the R-loom-multi-thread Run loom multi-thread tests on this PR label Feb 17, 2024
…ns (#6355)

* Fixes segfault in park_timeout() on riscv64
@leso-kn
Copy link
Author

leso-kn commented Feb 17, 2024

Note on the minrust CI job: The black_box() hint has been stabilized since rust version 1.66.0 (minrust uses 1.63.0)

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Feb 17, 2024
@Darksonn
Copy link
Contributor

Closing for the reasons outlined in #6355 (comment).

@Darksonn Darksonn closed this Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime R-loom-multi-thread Run loom multi-thread tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants