Closed
Description
Code
use aya::Bpf;
use aya_log::BpfLogger;
use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
pub mod cgroup_sock_addr_version;
pub mod kprobe_version;
pub mod sockops_version;
pub fn init_log(bpf: &mut Bpf) {
TermLogger::init(
LevelFilter::Debug,
ConfigBuilder::new()
.set_target_level(LevelFilter::Info)
.set_location_level(LevelFilter::Info)
.build(),
TerminalMode::Mixed,
ColorChoice::Auto,
)
.unwrap();
// Will log using the default logger, which is TermLogger in this case
BpfLogger::init(bpf).unwrap();
}
use std::env;
use aya::programs::SockOps;
use aya::Bpf;
use tokio::fs::File;
use tokio::signal;
use crate::init_log;
pub async fn load_sockops() {
let path = env::args().nth(1).unwrap();
let mut bpf = Bpf::load_file(&path).unwrap();
let prog: &mut SockOps = bpf
.program_mut("sockops_connect")
.unwrap()
.try_into()
.unwrap();
prog.load().unwrap();
let file = File::open("/sys/fs/cgroup").await.unwrap();
let link_id = prog.attach(file).unwrap();
let _owned_link = prog.take_link(link_id).unwrap();
println!("loaded");
init_log(&mut bpf);
signal::ctrl_c().await.unwrap()
}
the main.rs
#[tokio::main]
async fn main() {
user::sockops_version::load_sockops().await;
}
Meta
rustc --version --verbose
:
rustc 1.64.0-nightly (c2f428d2f 2022-07-14)
binary: rustc
commit-hash: c2f428d2f3340a0e7d995f4726223db91b93704c
commit-date: 2022-07-14
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Error output
Compiling time v0.3.11
Compiling thiserror-impl v1.0.31
Compiling tokio-macros v1.8.0
Compiling futures v0.3.21
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 2', compiler/rustc_builtin_macros/src/format.rs:1001:28
stack backtrace:
0: 0x7fa9066a2950 - std::backtrace_rs::backtrace::libunwind::trace::heeafe1f1ea6b4c2f
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
1: 0x7fa9066a2950 - std::backtrace_rs::backtrace::trace_unsynchronized::hf08684e78cd6c167
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7fa9066a2950 - std::sys_common::backtrace::_print_fmt::had9e99c2c8763a1e
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys_common/backtrace.rs:66:5
3: 0x7fa9066a2950 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b4c432d2a1e6303
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys_common/backtrace.rs:45:22
4: 0x7fa9066fbf2c - core::fmt::write::h87085de871a99231
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/fmt/mod.rs:1198:17
5: 0x7fa906694015 - std::io::Write::write_fmt::h7635d2f423aa55dc
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/io/mod.rs:1672:15
6: 0x7fa9066a55e1 - std::sys_common::backtrace::_print::hc003bc1c22b7967b
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys_common/backtrace.rs:48:5
7: 0x7fa9066a55e1 - std::sys_common::backtrace::print::h1baa1ab7758e52b0
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys_common/backtrace.rs:35:9
8: 0x7fa9066a55e1 - std::panicking::default_hook::{{closure}}::he2f5e84c6ab77817
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:295:22
9: 0x7fa9066a52b3 - std::panicking::default_hook::h3f96069db270c68f
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:314:9
10: 0x7fa906f49de4 - rustc_driver[1ce26eb46f30f4d]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7fa9066a5db6 - std::panicking::rust_panic_with_hook::hed0c1597bbc695a6
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:702:17
12: 0x7fa9066a5c07 - std::panicking::begin_panic_handler::{{closure}}::h0fc9e6b3154da131
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:588:13
13: 0x7fa9066a2e34 - std::sys_common::backtrace::__rust_end_short_backtrace::hb9c2240a67931ff9
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys_common/backtrace.rs:138:18
14: 0x7fa9066a5932 - rust_begin_unwind
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:584:5
15: 0x7fa906669c33 - core::panicking::panic_fmt::h6bda1b0556b509cd
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:142:14
16: 0x7fa906669b72 - core::panicking::panic_bounds_check::hf8fc252dfbb36006
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:84:5
17: 0x7fa909384643 - rustc_builtin_macros[6a564b3b10d3c327]::format::expand_preparsed_format_args
18: 0x7fa90937ddac - rustc_builtin_macros[6a564b3b10d3c327]::format::expand_format_args_impl
19: 0x7fa908cbcbed - <rustc_expand[ec7f7165620ca96d]::expand::MacroExpander>::fully_expand_fragment
20: 0x7fa90983194b - <rustc_expand[ec7f7165620ca96d]::expand::MacroExpander>::expand_crate
21: 0x7fa909156aa2 - <rustc_session[4ac326324d613686]::session::Session>::time::<core[32c218dbf3427c26]::result::Result<rustc_ast[f9ddef6e3c579104]::ast::Crate, rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_interface[694c7ab70a1d38bc]::passes::configure_and_expand::{closure#1}>
22: 0x7fa909140832 - rustc_interface[694c7ab70a1d38bc]::passes::configure_and_expand
23: 0x7fa90914d2c1 - <rustc_interface[694c7ab70a1d38bc]::queries::Queries>::expansion
24: 0x7fa90910bfcc - <rustc_interface[694c7ab70a1d38bc]::interface::Compiler>::enter::<rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}::{closure#2}, core[32c218dbf3427c26]::result::Result<core[32c218dbf3427c26]::option::Option<rustc_interface[694c7ab70a1d38bc]::queries::Linker>, rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>
25: 0x7fa9091081ff - rustc_span[717885ec7c6cd182]::with_source_map::<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_interface[694c7ab70a1d38bc]::interface::create_compiler_and_run<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}>::{closure#1}>
26: 0x7fa9091244b0 - rustc_interface[694c7ab70a1d38bc]::interface::create_compiler_and_run::<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}>
27: 0x7fa9091385b2 - <scoped_tls[f235d80db834c386]::ScopedKey<rustc_span[717885ec7c6cd182]::SessionGlobals>>::set::<rustc_interface[694c7ab70a1d38bc]::interface::run_compiler<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}>::{closure#0}, core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>
28: 0x7fa90910a78f - std[167b23ae759531ff]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[694c7ab70a1d38bc]::util::run_in_thread_pool_with_globals<rustc_interface[694c7ab70a1d38bc]::interface::run_compiler<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}>::{closure#0}, core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>::{closure#0}, core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>
29: 0x7fa909124909 - <<std[167b23ae759531ff]::thread::Builder>::spawn_unchecked_<rustc_interface[694c7ab70a1d38bc]::util::run_in_thread_pool_with_globals<rustc_interface[694c7ab70a1d38bc]::interface::run_compiler<core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>, rustc_driver[1ce26eb46f30f4d]::run_compiler::{closure#1}>::{closure#0}, core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>::{closure#0}, core[32c218dbf3427c26]::result::Result<(), rustc_errors[3b3e5bcd1e9c2834]::ErrorGuaranteed>>::{closure#1} as core[32c218dbf3427c26]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
30: 0x7fa9066af803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h86b1834fb0da834b
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/alloc/src/boxed.rs:1934:9
31: 0x7fa9066af803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h124d05192aaf60e0
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/alloc/src/boxed.rs:1934:9
32: 0x7fa9066af803 - std::sys::unix::thread::Thread::new::thread_start::h01e8d05fb6e030ea
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/sys/unix/thread.rs:108:17
33: 0x7fa90648054d - <unknown>
34: 0x7fa906505874 - clone
35: 0x0 - <unknown>
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.64.0-nightly (c2f428d2f 2022-07-14) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C linker=clang -C link-arg=-fuse-ld=mold
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `time`
warning: build failed, waiting for other jobs to finish...
Backtrace
Compiling time v0.3.11
Compiling tokio v1.19.2
Compiling thiserror v1.0.31
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 2', compiler/rustc_builtin_macros/src/format.rs:1001:28
stack backtrace:
0: rust_begin_unwind
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:142:14
2: core::panicking::panic_bounds_check
at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:84:5
3: rustc_builtin_macros::format::expand_preparsed_format_args
4: rustc_builtin_macros::format::expand_format_args_impl
5: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
6: <rustc_expand::expand::MacroExpander>::expand_crate
7: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}>
8: rustc_interface::passes::configure_and_expand
9: <rustc_interface::queries::Queries>::expansion
10: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
11: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
12: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
13: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.64.0-nightly (c2f428d2f 2022-07-14) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C linker=clang -C link-arg=-fuse-ld=mold
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `time`
warning: build failed, waiting for other jobs to finish..