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
[libc-0.2] posix_spawn_file_actions_t
cannot be used on Linux after #3602
#3608
Labels
C-bug
Category: bug
Comments
@JohnTitor: This is blocking updating |
The problematic PR has been reverted in #3678. |
After wasting a day, I also found out that posix_spawnattr_init is fine in 0.2.153, but 0.2.154 causes Segmentation fault...... |
This was referenced May 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We found an issue when updating ferrocene's libc submodule (ferrocene/ferrocene#356) to revision 947a185 . the only change included in our libc update was PR #3602 .
when building stage 2 of libstd to x86_64-linux the build failed to execute the build script of the
quote
crate with the following error:where the mentioned line corresponds to this revision.
Tracking down the error led us to this usage of the
posix_spawn
API:This code allocates a
posix_spawn_file_actions_init
type on the stack. before #3602, thefile_actions
stack variable had the correct size and alignment but after #3602, it now has a size and alignment of*mut c_void
(8 bytes on x86_64) and that results in UB whenposix_spawn_file_actions_init
is called.GLIBC implements
posix_spawn_file_actions_init
as a memset operation that zeroes the struct. In Rust syntax, that would be more or less this code:Bionic implements
posix_spawn_file_actions_init
differently. It uses a heap allocation as indirection. The Rust version of the bionic implementation looks roughly like this:This usage of
posix_spawn_file_actions_t
in libstd:is compatible with both GLIBC and Bionic but the
libc
crate needs to provide the correct size and alignment on Linux.So, the conditional code should produce this on Linux
but this on Android
All this probably also applies to the
posix_spawnattr_t
type but I have yet to look into the details of the GLIBC code around that type.I'll send up a fix PR after I have done some more testing.
The text was updated successfully, but these errors were encountered: