Build fails on 32-bit glibc (i686, armv7) with libc's `--cfg=libc_unstable_time64`: `tv_usec` is cast to `suseconds_t` (i32) for an i64 field
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Đọc src/sys/unix.rs tại into_timeval, nơi issue nêu cast của tv_usec, và so sánh với kiểu trường timeval của libc trong cấu hình time64. Báo cáo đề xuất để trường struct suy luận kiểu cast; hãy kiểm tra bản dựng thành công trên i686 và armv7 khi có và không có cfg, cũng như trên x86_64. Công việc hoàn tất khi các cấu hình đó biên dịch không có cảnh báo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
socket2 does not compile for 32-bit glibc targets when libc's 64-bit time_t opt-in is on: RUSTFLAGS='--cfg=libc_unstable_time64' with libc ≥ 0.2.190 (earlier spellings of the same configuration: --cfg=libc_unstable_gnu_time_bits="64" from 0.2.187, RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 before that).
Under that configuration libc follows glibc's _TIME_BITS=64: timeval::tv_usec becomes __suseconds64_t (i64) while suseconds_t stays 32-bit, as it does in glibc. From libc 0.2.191, src/unix/mod.rs:71-79:
pub struct timeval {
pub tv_sec: time_t,
#[cfg(not(gnu_time_bits64))]
pub tv_usec: crate::suseconds_t,
// For 64 bit time on 32 bit linux glibc, suseconds_t is still
// a 32 bit type. Use __suseconds64_t instead
#[cfg(gnu_time_bits64)]
pub tv_usec: __suseconds64_t,
}
into_timeval casts to suseconds_t, so the struct literal gets an i32 where the field is i64. socket2 0.6.5, src/sys/unix.rs:1249-1262 (the same line is :1244 in 0.6.4, :1240 in 0.5.10 and :1318 on master):
fn into_timeval(duration: Option<Duration>) -> libc::timeval {
match duration {
// https://github.com/rust-lang/libc/issues/1848
#[cfg_attr(target_env = "musl", allow(deprecated))]
Some(duration) => libc::timeval {
tv_sec: min(duration.as_secs(), libc::time_t::MAX as u64) as libc::time_t,
tv_usec: duration.subsec_micros() as libc::suseconds_t,
},
None => libc::timeval {
tv_sec: 0,
tv_usec: 0,
},
}
}
Measured: socket2 0.5.10, 0.6.4 and 0.6.5 with libc 0.2.191, on i686-unknown-linux-gnu and armv7-unknown-linux-gnueabihf, rustc 1.98.1. Without the cfg all three build; with it each fails with this one error (0.6.5 on armv7; i686 is identical):
error[E0308]: mismatched types
--> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/socket2-0.6.5/src/sys/unix.rs:1255:22
|
1255 | tv_usec: duration.subsec_micros() as libc::suseconds_t,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i64`, found `i32`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `socket2` (lib) due to 1 previous error
Reproduction: an empty library crate with
[dependencies]
socket2 = "=0.6.5"
libc = "=0.2.191"
and RUSTFLAGS='--cfg=libc_unstable_time64' cargo check --target i686-unknown-linux-gnu (or --target armv7-unknown-linux-gnueabihf).
A possible fix: tv_usec: duration.subsec_micros() as _, lets the field pick its type. With that one change 0.6.5 builds on i686, armv7 and x86_64, with and without the cfg, with no warnings.
The cast is private, so the change does not touch socket2's API. nix hits the same libc change in its public TimeVal API (nix-rust/nix#2778); libc's time64 tracking issue is rust-lang/libc#5507, and libc's 0.2.190 release notes ask for exactly this kind of report.
- Ngôn ngữ chính
- Rust
- Star
- 885
- Fork
- 328
- Merge trung bình
- 6 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/socket2
-
Commit lockfileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
rust-lang/socket2#703 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
windows-sys 0.101.0Có thể đã có người làm @xtqqczze đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`from_timeval` overflows on a non-normalised `tv_usec`Có thể đã có người làm @pederbe đã nhận 18 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sendfile violates I/O-safetyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rust-lang/socket2#683 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/socket2
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
infra
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
available bug good first issue tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Nixitov/Riptide-Native#817 ·
Maintainer thường phản hồi trong vòng 1 ngày