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

Undefined behavior in SigEvent::new on Fuchsia #1441

Closed
asomers opened this issue May 30, 2021 · 1 comment · Fixed by #2079
Closed

Undefined behavior in SigEvent::new on Fuchsia #1441

asomers opened this issue May 30, 2021 · 1 comment · Fixed by #2079

Comments

@asomers
Copy link
Member

asomers commented May 30, 2021

Beginning with Rust 1.41.0, the build fails on Fuchsia. It triggers this error:

error: the type `libc::sigevent` does not permit zero-initialization
   --> src/sys/signal.rs:855:36
    |
855 |             let mut sev = unsafe { mem::MaybeUninit::<libc::sigevent>::zeroed().assume_init() };
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                    |
    |                                    this code causes undefined behavior when executed
    |                                    help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done

Judging by the comments, the original author of Fuchsia support was aware of this problem and tried to work around it. However, later versions of the Rust compiler got more strict. Since Fuchsia is tier-3, I'm just going to disable the warning (on Fuchsia only) to fix the build. @amanda-tait would you be willing to devise a more permanent solution?

asomers added a commit to asomers/nix that referenced this issue May 30, 2021
Beginning with 1.41.0, Rust considers it UB to zero-initialize a
function pointer, even if you try to hide it behind `mem::MaybeUninit`.
Suppress this warning to fix the build until we come up with a better
permanent solution.

Issue nix-rust#1441
asomers added a commit to asomers/nix that referenced this issue May 30, 2021
Beginning with 1.41.0, Rust considers it UB to zero-initialize a
function pointer, even if you try to hide it behind `mem::MaybeUninit`.
Suppress this warning to fix the build until we come up with a better
permanent solution.

Issue nix-rust#1441
asomers added a commit to asomers/nix that referenced this issue Jul 17, 2023
It triggers UB, which the compiler warns about beginning with 1.41.0.
Remove it, due to lack of a Fuchsia maintainer and lack of feedback from
the original Fuchsia porter.

Fixes nix-rust#1441
asomers added a commit to asomers/nix that referenced this issue Jul 17, 2023
It triggers UB, which the compiler warns about beginning with 1.41.0.
Remove it, due to lack of a Fuchsia maintainer and lack of feedback from
the original Fuchsia porter.

Fixes nix-rust#1441
@tamird
Copy link
Contributor

tamird commented Jul 17, 2023

My apologies about the lack of response from @amanda-tait. I was not aware of this issue. Fuchsia doesn't have a concept of signals.

bors bot added a commit that referenced this issue Jul 18, 2023
2079: Remove sigevent support on Fuchsia r=asomers a=asomers

It triggers UB, which the compiler warns about beginning with 1.41.0. Remove it, due to lack of a Fuchsia maintainer and lack of feedback from the original Fuchsia porter.

Fixes #1441

Co-authored-by: Alan Somers <asomers@gmail.com>
bors bot added a commit that referenced this issue Aug 6, 2023
2079: Remove sigevent support on Fuchsia r=asomers a=asomers

It triggers UB, which the compiler warns about beginning with 1.41.0. Remove it, due to lack of a Fuchsia maintainer and lack of feedback from the original Fuchsia porter.

Fixes #1441

Co-authored-by: Alan Somers <asomers@gmail.com>
@bors bors bot closed this as completed in 625287e Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants