初识rust


调试下rust 的执行流程

参考:

认识 Cargo - Rust语言圣经(Rust Course)

新建一个hello world 程序:

fn main() {println!("Hello, world!");
}

用IDA 打开exe,并加载符号:

根据字符串找到主程序入口:

双击该符号,然后按x,快捷键,查看所有的符号引用:

之后跳转到对应的程序位置:

PE 起始地址为140000000

读取"hello,world"字符的指令地址:140001040:

使用windbg ,加载该程序,并在lea 指令的位置下断点:

0:000> kp# Child-SP          RetAddr               Call Site
00 000000e6`c38ff9a8 00007ff7`b2571006     hello_world!__ImageBase
01 000000e6`c38ff9b0 00007ff7`b257101c     hello_world!__ImageBase
02 000000e6`c38ff9e0 00007ff7`b25736a8     hello_world!__ImageBase
03 (Inline Function) --------`--------     hello_world!std::rt::lang_start_internal::closure$2(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs @ 148] 
04 (Inline Function) --------`--------     hello_world!std::panicking::try::do_call(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs @ 502] 
05 (Inline Function) --------`--------     hello_world!std::panicking::try(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs @ 466] 
06 (Inline Function) --------`--------     hello_world!std::panic::catch_unwind(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs @ 142] 
07 000000e6`c38ffa10 00007ff7`b25710ac     hello_world!std::rt::lang_start_internal(void)+0xb8 [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs @ 148] 
08 000000e6`c38ffb10 00007ff7`b258a510     hello_world!main+0x2c
09 (Inline Function) --------`--------     hello_world!invoke_main(void)+0x22 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78] 
0a 000000e6`c38ffb50 00007ffc`c2a0257d     hello_world!__scrt_common_main_seh(void)+0x10c [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
0b 000000e6`c38ffb90 00007ffc`c39caa78     KERNEL32!BaseThreadInitThunk+0x1d
0c 000000e6`c38ffbc0 00000000`00000000     ntdll!RtlUserThreadStart+0x28
//! Runtime services
//!
//! The `rt` module provides a narrow set of runtime services,
//! including the global heap (exported in `heap`) and unwinding and
//! backtrace support. The APIs in this module are highly unstable,
//! and should be considered as private implementation details for the
//! time being.#![unstable(feature = "rt",reason = "this public module should not exist and is highly likely \to disappear",issue = "none"
)]
#![doc(hidden)]
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(unused_macros)]use crate::ffi::CString;// Re-export some of our utilities which are expected by other crates.
pub use crate::panicking::{begin_panic, panic_count};
pub use core::panicking::{panic_display, panic_fmt};use crate::sync::Once;
use crate::sys;
use crate::sys_common::thread_info;
use crate::thread::Thread;// Prints to the "panic output", depending on the platform this may be:
// - the standard error output
// - some dedicated platform specific output
// - nothing (so this macro is a no-op)
macro_rules! rtprintpanic {($($t:tt)*) => {if let Some(mut out) = crate::sys::stdio::panic_output() {let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*));}}
}macro_rules! rtabort {($($t:tt)*) => {{rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));crate::sys::abort_internal();}}
}macro_rules! rtassert {($e:expr) => {if !$e {rtabort!(concat!("assertion failed: ", stringify!($e)));}};
}macro_rules! rtunwrap {($ok:ident, $e:expr) => {match $e {$ok(v) => v,ref err => {let err = err.as_ref().map(drop); // map Ok/Some which might not be Debugrtabort!(concat!("unwrap failed: ", stringify!($e), " = {:?}"), err)}}};
}// One-time runtime initialization.
// Runs before `main`.
// SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
//
// # The `sigpipe` parameter
//
// Since 2014, the Rust runtime on Unix has set the `SIGPIPE` handler to
// `SIG_IGN`. Applications have good reasons to want a different behavior
// though, so there is a `#[unix_sigpipe = "..."]` attribute on `fn main()` that
// can be used to select how `SIGPIPE` shall be setup (if changed at all) before
// `fn main()` is called. See <https://github.com/rust-lang/rust/issues/97889>
// for more info.
//
// The `sigpipe` parameter to this function gets its value via the code that
// rustc generates to invoke `fn lang_start()`. The reason we have `sigpipe` for
// all platforms and not only Unix, is because std is not allowed to have `cfg`
// directives as this high level. See the module docs in
// `src/tools/tidy/src/pal.rs` for more info. On all other platforms, `sigpipe`
// has a value, but its value is ignored.
//
// Even though it is an `u8`, it only ever has 4 values. These are documented in
// `compiler/rustc_session/src/config/sigpipe.rs`.
#[cfg_attr(test, allow(dead_code))]
unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {unsafe {sys::init(argc, argv, sigpipe);let main_guard = sys::thread::guard::init();// Next, set up the current Thread with the guard information we just// created. Note that this isn't necessary in general for new threads,// but we just do this to name the main thread and to give it correct// info about the stack bounds.let thread = Thread::new(Some(rtunwrap!(Ok, CString::new("main"))));thread_info::set(main_guard, thread);}
}// One-time runtime cleanup.
// Runs after `main` or at program exit.
// NOTE: this is not guaranteed to run, for example when the program aborts.
pub(crate) fn cleanup() {static CLEANUP: Once = Once::new();CLEANUP.call_once(|| unsafe {// Flush stdout and disable buffering.crate::io::cleanup();// SAFETY: Only called once during runtime cleanup.sys::cleanup();});
}// To reduce the generated code of the new `lang_start`, this function is doing
// the real work.
#[cfg(not(test))]
fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + crate::panic::RefUnwindSafe),argc: isize,argv: *const *const u8,sigpipe: u8,
) -> Result<isize, !> {use crate::{mem, panic};let rt_abort = move |e| {mem::forget(e);rtabort!("initialization or cleanup bug");};// Guard against the code called by this function from unwinding outside of the Rust-controlled// code, which is UB. This is a requirement imposed by a combination of how the// `#[lang="start"]` attribute is implemented as well as by the implementation of the panicking// mechanism itself.//// There are a couple of instances where unwinding can begin. First is inside of the// `rt::init`, `rt::cleanup` and similar functions controlled by bstd. In those instances a// panic is a std implementation bug. A quite likely one too, as there isn't any way to// prevent std from accidentally introducing a panic to these functions. Another is from// user code from `main` or, more nefariously, as described in e.g. issue #86030.// SAFETY: Only called once during runtime initialization.panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_err(rt_abort)?;let ret_code = panic::catch_unwind(move || panic::catch_unwind(main).unwrap_or(101) as isize).map_err(move |e| {mem::forget(e);rtabort!("drop of the panic payload panicked");});panic::catch_unwind(cleanup).map_err(rt_abort)?;ret_code
}#[cfg(not(test))]
#[lang = "start"]
fn lang_start<T: crate::process::Termination + 'static>(main: fn() -> T,argc: isize,argv: *const *const u8,sigpipe: u8,
) -> isize {let Ok(v) = lang_start_internal(&move || crate::sys_common::backtrace::__rust_begin_short_backtrace(main).report().to_i32(),argc,argv,sigpipe,);v
}

其核心运行时如上

panic

看起来是利用panic 库进行一些基本的异常捕获与异常处理。

panic! 深入剖析 - Rust语言圣经(Rust Course)

实验:

主动 异常
fn main() {panic!("crash and burn");
}
PS E:\learn\rust\panic_test> $env:RUST_BACKTRACE="full" ; cargo run releaseCompiling panic_test v0.1.0 (E:\learn\rust\panic_test)Finished dev [unoptimized + debuginfo] target(s) in 0.18sRunning `target\debug\panic_test.exe release`
thread 'main' panicked at src\main.rs:2:5:
crash and burn
stack backtrace:0:     0x7ff7a439709a - std::sys_common::backtrace::_print::impl$0::fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:441:     0x7ff7a43a52db - core::fmt::rt::Argument::fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\rt.rs:1382:     0x7ff7a43a52db - core::fmt::writeat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\mod.rs:10943:     0x7ff7a43953d1 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io\mod.rs:17144:     0x7ff7a4396e1a - std::sys_common::backtrace::_printat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:475:     0x7ff7a4396e1a - std::sys_common::backtrace::printat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:346:     0x7ff7a4398e4a - std::panicking::default_hook::closure$1at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:2707:     0x7ff7a4398ab8 - std::panicking::default_hookat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:2908:     0x7ff7a43994fe - std::panicking::rust_panic_with_hookat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:7079:     0x7ff7a43993aa - std::panicking::begin_panic_handler::closure$0at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:59710:     0x7ff7a4397a89 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:170    11:     0x7ff7a43990f0 - std::panicking::begin_panic_handlerat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:59512:     0x7ff7a43aa235 - core::panicking::panic_fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:6713:     0x7ff7a43910a1 - panic_test::mainat E:\learn\rust\panic_test\src\main.rs:214:     0x7ff7a439123b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:25015:     0x7ff7a439119e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    16:     0x7ff7a439119e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    17:     0x7ff7a4391061 - std::rt::lang_start::closure$0<tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:16618:     0x7ff7a4393558 - std::rt::lang_start_internal::closure$2at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:14819:     0x7ff7a4393558 - std::panicking::try::do_callat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:50220:     0x7ff7a4393558 - std::panicking::tryat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:46621:     0x7ff7a4393558 - std::panic::catch_unwindat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs:14222:     0x7ff7a4393558 - std::rt::lang_start_internalat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:14823:     0x7ff7a439103a - std::rt::lang_start<tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:16524:     0x7ff7a43910c9 - main25:     0x7ff7a43a8c80 - invoke_mainat D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:7826:     0x7ff7a43a8c80 - __scrt_common_main_sehat D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:28827:     0x7ffcc2a0257d - BaseThreadInitThunk28:     0x7ffcc39caa78 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\panic_test.exe release` (exit code: 101)
被动 异常
fn main() {let v = vec![1, 2, 3];v[99];
}
PS E:\learn\rust\panic_test> $env:RUST_BACKTRACE="full" ; cargo run releaseFinished dev [unoptimized + debuginfo] target(s) in 0.00sRunning `target\debug\panic_test.exe release`
thread 'main' panicked at src\main.rs:4:6:
index out of bounds: the len is 3 but the index is 99
stack backtrace:0:     0x7ff75aca794a - std::sys_common::backtrace::_print::impl$0::fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:441:     0x7ff75acb5c1b - core::fmt::rt::Argument::fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\rt.rs:1382:     0x7ff75acb5c1b - core::fmt::writeat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\mod.rs:10943:     0x7ff75aca5c81 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io\mod.rs:17144:     0x7ff75aca76ca - std::sys_common::backtrace::_printat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:475:     0x7ff75aca76ca - std::sys_common::backtrace::printat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:346:     0x7ff75aca978a - std::panicking::default_hook::closure$1at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:2707:     0x7ff75aca93f8 - std::panicking::default_hookat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:2908:     0x7ff75aca9e3e - std::panicking::rust_panic_with_hookat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:7079:     0x7ff75aca9d2d - std::panicking::begin_panic_handler::closure$0at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:59910:     0x7ff75aca8339 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:170    11:     0x7ff75aca9a30 - std::panicking::begin_panic_handlerat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:59512:     0x7ff75acbab75 - core::panicking::panic_fmtat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:6713:     0x7ff75acbacee - core::panicking::panic_bounds_checkat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:16214:     0x7ff75aca1afd - core::slice::index::impl$2::index<i32>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\slice\index.rs:26115:     0x7ff75aca1076 - alloc::vec::impl$12::index<i32,usize,alloc::alloc::Global>at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\alloc\src\vec\mod.rs:267516:     0x7ff75aca1366 - panic_test::mainat E:\learn\rust\panic_test\src\main.rs:417:     0x7ff75aca14ab - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:25018:     0x7ff75aca13de - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    19:     0x7ff75aca13de - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    20:     0x7ff75aca12e1 - std::rt::lang_start::closure$0<tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:16621:     0x7ff75aca3e08 - std::rt::lang_start_internal::closure$2at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:14822:     0x7ff75aca3e08 - std::panicking::try::do_callat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:50223:     0x7ff75aca3e08 - std::panicking::tryat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:46624:     0x7ff75aca3e08 - std::panic::catch_unwindat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs:14225:     0x7ff75aca3e08 - std::rt::lang_start_internalat /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:14826:     0x7ff75aca12ba - std::rt::lang_start<tuple$<> >at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:16527:     0x7ff75aca13c9 - main28:     0x7ff75acb95c0 - invoke_mainat D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:7829:     0x7ff75acb95c0 - __scrt_common_main_sehat D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:28830:     0x7ffcc2a0257d - BaseThreadInitThunk31:     0x7ffcc39caa78 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\panic_test.exe release` (exit code: 101)

可以看到,包括我们用windbg 看到的,比较完整的js 运行时的入口都看到了

 rust 程序main 入口前,就已经安装了一个默认的panic handler ,用来打印一些全局的错误信息,和堆栈列表。

rt.rs 详解

int __cdecl main(int argc, const char **argv, const char **envp)
{char v4; // [rsp+20h] [rbp-18h]__int64 (__fastcall *v5)(); // [rsp+30h] [rbp-8h] BYREFv5 = sub_140001040;v4 = 0;return std::rt::lang_start_internal::h8a2184178aa988dc(&v5, &off_14001D360, argc, argv, v4);
}

其中,sub_140001040 即为main 函数:

 

__int64 sub_140001040()
{__int64 v1[3]; // [rsp+28h] [rbp-30h] BYREF__int128 v2; // [rsp+40h] [rbp-18h]v1[0] = (__int64)&off_14001D3A0;v1[1] = 1i64;v1[2] = (__int64)"called `Option::unwrap()` on a `None` value";v2 = 0i64;return std::io::stdio::_print::h445fdab5382e0576(v1);
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/181499.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python模块的介绍和导入

python模块的介绍和导入 概念 在Python中&#xff0c;每个Python代码文件都是一个模块。写程序时&#xff0c;我们可以将代码分散在不同的模块(文件)中&#xff0c;然后在一个模块中引用另一个模块的内容。 导入格式 1、在一个模块中引用(导入)另一个模块可以使用import语句…

web前端——HTML+CSS实现九宫格

web前端——HTMLCSS实现九宫格 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>Document</title&…

大数据毕业设计选题推荐-无线网络大数据平台-Hadoop-Spark-Hive

✨作者主页&#xff1a;IT毕设梦工厂✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Py…

【JavaEE】JVM 剖析

JVM 1. JVM 的内存划分2. JVM 类加载机制2.1 类加载的大致流程2.2 双亲委派模型2.3 类加载的时机 3. 垃圾回收机制3.1 为什么会存在垃圾回收机制?3.2 垃圾回收, 到底实在做什么?3.3 垃圾回收的两步骤第一步: 判断对象是否是"垃圾"第二步: 如何回收垃圾 1. JVM 的内…

Linux MMC子系统 - 3.eMMC 5.1常用命令说明(1)

By: Ailson Jack Date: 2023.11.05 个人博客&#xff1a;http://www.only2fire.com/ 本文在我博客的地址是&#xff1a;http://www.only2fire.com/archives/162.html&#xff0c;排版更好&#xff0c;便于学习&#xff0c;也可以去我博客逛逛&#xff0c;兴许有你想要的内容呢。…

SpringBoot 将 jar 包和 lib 依赖分离,dockerfile 构建镜像

前言 Spring Boot 是一个非常流行的 Java 开发框架&#xff0c;它提供了很多便利的功能&#xff0c;例如自动配置、快速开发等等。 在使用 Spring Boot 进行开发时&#xff0c;我们通常会使用 Maven 或 Gradle 进行项目构建。 本文将为您介绍如何使用 Maven 将 Spring Boot …

项目实战:新增@Controller和@Service@Repository@Autowire四个注解

1、Controller package com.csdn.mymvc.annotation; import java.lang.annotation.*; Target(ElementType.TYPE) Retention(RetentionPolicy.RUNTIME) Inherited public interface Controller { }2、Service package com.csdn.mymvc.annotation; import java.lang.annotation.*…

上线Spring boot-若依项目

基础环境 所有环境皆关闭防火墙与selinux 服务器功能主机IP主机名服务名称配置前端服务器192.168.231.177nginxnginx1C2G后端服务器代码打包192.168.231.178javajava、maven、nodejs4C8G数据库/缓存192.168.231.179dbmysql、redis2C4G Nginx #配置Nginxyum源 [rootnginx ~]…

大语言模型对齐技术 最新论文及源码合集(外部对齐、内部对齐、可解释性)

大语言模型对齐(Large Language Model Alignment)是利用大规模预训练语言模型来理解它们内部的语义表示和计算过程的研究领域。主要目的是避免大语言模型可见的或可预见的风险&#xff0c;比如固有存在的幻觉问题、生成不符合人类期望的文本、容易被用来执行恶意行为等。 从必…

[原创]Cadence17.4,win64系统,构建CIS库

目录 1、背景介绍 2、具体操作流程 3、遇到问题、分析鉴别问题、解决问题 4、借鉴链接并评论 1、背景介绍 CIS库&#xff0c;绘制原理图很方便&#xff0c;但是需要在Cadence软件与数据库之间建立联系&#xff0c;但是一直不成功&#xff0c;花费半天时间才搞明白如何建立关系并…

[LeetCode] 2.两数相加

一、题目描述 给你两个 非空 的链表&#xff0c;表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的&#xff0c;并且每个节点只能存储 一位 数字。 请你将两个数相加&#xff0c;并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外&#xff0c;这两个…

Idea 对容器中的 Java 程序断点远程调试

第一种&#xff1a;简单粗暴型 直接在java程序中添加log.info()&#xff0c;根据需要打印信息然后打包覆盖&#xff0c;根据日志查看相关信息 第二种&#xff1a;远程调试 在IDEA右上角点击编辑配置设置相关参数在Dockerfile中加入 "-jar", "-agentlib:jdwp…

【Redis】安装(Linuxwindow)及Redis的常用命令

一&#xff0c;Redis简介 Redis是一个开源&#xff08;BSD许可&#xff09;&#xff0c;内存存储的数据结构服务器&#xff0c;可用作数据库&#xff0c;高速缓存和消息队列代理。 它支持字符串、哈希表、列表、集合、有序集合&#xff0c;位图&#xff0c;hyperloglogs等数…

Java通过cellstyle属性设置Excel单元格常用样式全面总结

最近做了一个导出Excel的功能&#xff0c;导出是个常规导出&#xff0c;但是拿来模板一看&#xff0c;有一些单元格的样式设置&#xff0c;包括合并&#xff0c;背景色&#xff0c;字体等等&#xff0c;毕竟不是常用的东西&#xff0c;需要查阅资料完成&#xff0c;但是搜遍全网…

Java21-虚拟线程小试牛刀-meethigher

其他语言&#xff0c;如Go早期就支持了叫做协程的东西&#xff0c;它是轻量化后的线程&#xff0c;而Java异步编程却只有线程的概念。JDK8以后的升级带来的改变总体感觉不大&#xff0c;不过这次JDK21带来的Virtual Thread还是值得体验一把的&#xff0c;可以说是YYDS&#xff…

【多线程】Lambda表达式

package org.example;public class TestLambda {public static void main(String[] args) {Like likenew Like();like.lambda();}}//定义一个函数式接口 interface ILike{void lambda(); }//实现类 class Like implements ILike{Overridepublic void lambda() {System.out.prin…

网络层重要协议 --- IP协议

小王学习录 今日摘录IP数据报数据报首部IPv4的局限及解决方法 地址管理路由选择扩展&#xff1a;NAT和NAPT的结合使用 今日摘录 关山难越&#xff0c;谁悲失路之人。萍水相逢&#xff0c;尽是他乡之客。 网络层的职责是地址管理和路由选择&#xff0c;在网络层中最重要的协议…

SpringBoot整合Mybatis-plus

MyBatis-Plus与MyBatis区别&#xff1a; 导入坐标不同数据层实现简化 1.创建项目 2.选择依赖 3.pom文件 说明&#xff1a;配置pom.xml文件 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId>&…

【Java 进阶篇】JSP 简单入门

在现代Web开发中&#xff0c;JavaServer Pages&#xff08;JSP&#xff09;是一项非常重要的技术。JSP允许开发者将Java代码嵌入HTML页面&#xff0c;以实现动态内容的生成和呈现。本文将详细介绍JSP的概念、原理以及如何使用JSP来构建Web应用程序。 第一部分&#xff1a;JSP …

jetsonTX2 nx配置yolov5和D435I相机,完整步骤

转载一篇问题解决博客&#xff1a;问题解决 一、烧录系统 使用SDK烧录 二、安装archiconda3 JETSON TX2 NX的架构是aarch64,与win10,linxu不同,所以不能安装Anaconda&#xff0c;这里安装对应的archiconda。 1. 安装 wget https://github.com/Archiconda/build-tools/rel…