我正在试着使用图书馆users
[Docs.rs][GitHub].
当我使用以下代码try 获取MacOS上5号用户(即‘操作员’)的详细信息时...
use users::get_group_by_gid;
fn main() {
let group = get_group_by_gid(5).unwrap();
println!("{:?}", group.name());
}
...我收到一个意外错误:
thread 'main' panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x14400880b', /Users/dhruvkb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/users-0.11.0/src/base.rs:297:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'panic in a function that cannot unwind', library/core/src/panicking.rs:126:5
stack backtrace:
0: 0x104fe684c - std::backtrace_rs::backtrace::libunwind::trace::h0a647ce7e8dc2fab
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x104fe684c - std::backtrace_rs::backtrace::trace_unsynchronized::hea920694a2a8ac80
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x104fe684c - std::sys_common::backtrace::_print_fmt::h7b4e20c1da2ebb61
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
3: 0x104fe684c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h819e9cbdf1a9e730
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
4: 0x104ff80e0 - core::fmt::write::ha5e9bf3131ecb7c0
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
5: 0x104fe46b0 - std::io::Write::write_fmt::h414ce9994bf17404
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
6: 0x104fe6660 - std::sys_common::backtrace::_print::h28d98f2094da6d1d
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
7: 0x104fe6660 - std::sys_common::backtrace::print::h8072db0bbd5bcc3d
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
8: 0x104fe7b80 - std::panicking::default_hook::{{closure}}::h2c85c5b0c2ede151
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
9: 0x104fe7940 - std::panicking::default_hook::hcf2f70992d02f6fe
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
10: 0x104fe8058 - std::panicking::rust_panic_with_hook::h023af7f90b47eb8b
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:691:13
11: 0x104fe7f4c - std::panicking::begin_panic_handler::{{closure}}::h14283519edc1d634
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:580:13
12: 0x104fe6c6c - std::sys_common::backtrace::__rust_end_short_backtrace::hc366c0b0cef5b747
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
13: 0x104fe7d20 - rust_begin_unwind
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
14: 0x104fff6b8 - core::panicking::panic_nounwind_fmt::h48fca0782e5a5b33
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:96:14
15: 0x104fff734 - core::panicking::panic_nounwind::hc8dbc36c10163a33
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:126:5
16: 0x104fff82c - core::panicking::panic_cannot_unwind::h8bbe98643cda7e5c
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:188:5
17: 0x104fca054 - users::base::members::h897f0606a81fa18e
at /Users/dhruvkb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/users-0.11.0/src/base.rs:291:1
18: 0x104fc9bb0 - users::base::os::unix::GroupExtras::from_struct::hdb1f84273e3fef19
at /Users/dhruvkb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/users-0.11.0/src/base.rs:1060:33
19: 0x104fc9e44 - users::base::struct_to_group::h968dc5b5260e3ea2
at /Users/dhruvkb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/users-0.11.0/src/base.rs:280:19
20: 0x104fca3bc - users::base::get_group_by_gid::hbcac997dd823548f
at /Users/dhruvkb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/users-0.11.0/src/base.rs:473:26
21: 0x104fc875c - ug::main::h9b6b146ea9ce450b
at /Users/dhruvkb/Developer/personal/test/ug/src/main.rs:4:17
22: 0x104fc8908 - core::ops::function::FnOnce::call_once::h7e6c46cf308f75b9
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
23: 0x104fc8874 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1d5bc4a1fd871dea
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134:18
24: 0x104fc89ac - std::rt::lang_start::{{closure}}::hd278346b68dd1f23
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:166:18
25: 0x104fe2408 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6f7eb9f266759f90
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
26: 0x104fe2408 - std::panicking::try::do_call::h54b2febb9ea02379
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
27: 0x104fe2408 - std::panicking::try::h95a2f9f45aeb75ea
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
28: 0x104fe2408 - std::panic::catch_unwind::h9686256fa0fc97a1
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
29: 0x104fe2408 - std::rt::lang_start_internal::{{closure}}::h227e8b10bc4e486b
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
30: 0x104fe2408 - std::panicking::try::do_call::h414d500a3ee5fa44
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
31: 0x104fe2408 - std::panicking::try::h4f025820961f1c3f
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
32: 0x104fe2408 - std::panic::catch_unwind::h0b71dfe3538d125d
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
33: 0x104fe2408 - std::rt::lang_start_internal::h8ee16b8f6c950a26
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
34: 0x104fc8978 - std::rt::lang_start::hb3f96d07eed31802
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:165:17
35: 0x104fc8854 - _main
thread caused non-unwinding panic. aborting.
[1] 12348 abort cargo run
此错误是意外的,因为它适用于其他组ID,如0,即‘Root’或20,即,‘Staff’.
这发生在我的应用程序中,所以我创建了一个除了users
之外没有其他依赖项的新建项目,它也发生在那里.我知道exa
,一个流行的CLI应用程序使用这个库,所以我克隆了它的repo,并将main()
中的相同行添加到exa
‘S main()
函数中.
它在那里奏效,这更令人困惑.