Uh oh!
There was an error while loading. Please reload this page.
Use libc::sigaction() instead of sys::signal() to prevent a deadlock - #88828
Merged
Conversation
rust-highfive
commented
Sep 10, 2021
Contributor
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
FabianWolffforce-pushed
the
issue-88585
branch
from
September 10, 2021 19:02
a6c525d to
f1c8accComparev-lebedev
commented
Sep 15, 2021
I've tested the fix on Android Emulator x86-64 (Android 10), and on real devices (Android from 6.0.1 to 11). It works! |
FabianWolff
commented
Sep 15, 2021
ContributorAuthor
Happy to hear that! And thanks a lot for testing this @d3fl4t3! |
dtolnay
reviewed
Sep 29, 2021
Uh oh!
There was an error while loading. Please reload this page.
The reference automatically coerces to a pointer. Writing an explicit cast here is slightly misleading because that's most commonly used when a pointer needs to be converted from one pointer type to another, e.g. `*const c_void` to `*const sigaction` or vice versa.
dtolnay
approved these changes
Sep 29, 2021
dtolnay
commented
Sep 29, 2021
Member
@bors r+ |
bors
commented
Sep 29, 2021
Collaborator
📌 Commit e3e5ae9 has been approved by |
Manishearth added a commit
to Manishearth/rust
that referenced
this pull request
Sep 30, 2021
Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock Fixesrust-lang#88585. POSIX [specifies](https://man7.org/linux/man-pages/man3/fork.3p.html) that after forking, > to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called. Rust's standard library does not currently adhere to this, as evidenced by rust-lang#88585. The child process calls [`sys::signal()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/android.rs#L76), which on Android calls [`libc::dlsym()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/weak.rs#L101), which is [**not**](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, and in fact causes a deadlock in the example in rust-lang#88585. I think the easiest solution here would be to just call `libc::sigaction()` instead, which [is](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. [here](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/stack_overflow.rs#L112-L114).
Manishearth
commented
Sep 30, 2021
Member
@bors r- |
FabianWolff
commented
Oct 1, 2021
ContributorAuthor
dtolnay
approved these changes
Oct 3, 2021
dtolnay
commented
Oct 3, 2021
Member
@bors r+ |
bors
commented
Oct 3, 2021
Collaborator
📌 Commit 65ef265 has been approved by |
Manishearth added a commit
to Manishearth/rust
that referenced
this pull request
Oct 5, 2021
Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock Fixesrust-lang#88585. POSIX [specifies](https://man7.org/linux/man-pages/man3/fork.3p.html) that after forking, > to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called. Rust's standard library does not currently adhere to this, as evidenced by rust-lang#88585. The child process calls [`sys::signal()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/android.rs#L76), which on Android calls [`libc::dlsym()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/weak.rs#L101), which is [**not**](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, and in fact causes a deadlock in the example in rust-lang#88585. I think the easiest solution here would be to just call `libc::sigaction()` instead, which [is](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. [here](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/stack_overflow.rs#L112-L114).
bors added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 5, 2021
…arth Rollup of 10 pull requests Successful merges: - rust-lang#88706 (Normalize associated type projections when checking return type of main) - rust-lang#88828 (Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock) - rust-lang#88871 (Fix suggestion for nested struct patterns) - rust-lang#89317 (Move generic error message to separate branches) - rust-lang#89351 (for signed wrapping remainder, do not compare lhs with MIN) - rust-lang#89442 (Add check for duplicated doc aliases) - rust-lang#89502 (Fix Lower/UpperExp formatting for integers and precision zero) - rust-lang#89523 (Make `proc_macro_derive_resolution_fallback` a future-breakage lint) - rust-lang#89532 (Document behavior of `MaybeLiveLocals` regarding enums and field-senstivity) - rust-lang#89546 (Make an initial guess for metadata size to reduce buffer resizes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes#88585. POSIX specifies that after forking,
Rust's standard library does not currently adhere to this, as evidenced by #88585. The child process calls
sys::signal(), which on Android callslibc::dlsym(), which is not async-signal-safe, and in fact causes a deadlock in the example in #88585.I think the easiest solution here would be to just call
libc::sigaction()instead, which is async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. here.