Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ jobs:
with:
submodules: true
- name: Install Rust
run: rustup update 1.82.0 --no-self-update && rustup default 1.82.0
run: rustup update 1.88.0 --no-self-update && rustup default 1.88.0
- run: cargo build

miri:
Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ A library to acquire a stack trace (backtrace) at runtime in a Rust program.
"""
autoexamples = true
autotests = true
edition = "2021"
edition = "2024"
exclude = ["/ci/"]
rust-version = "1.82.0"
rust-version = "1.88.0"

[workspace]
members = ['crates/cpp_smoke_test', 'crates/as-if-std']
Expand Down Expand Up @@ -99,12 +99,10 @@ required-features = ["std"]
[[test]]
name = "smoke"
required-features = ["std"]
edition = '2021'

[[test]]
name = "accuracy"
required-features = ["std"]
edition = '2021'

[[test]]
name = "concurrent-panics"
Expand Down
2 changes: 1 addition & 1 deletion crates/as-if-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "as-if-std"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2021"
edition = "2024"
publish = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion crates/cpp_smoke_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cpp_smoke_test"
version = "0.1.0"
authors = ["Nick Fitzgerald <[email protected]>"]
edition = "2021"
edition = "2024"
build = "build.rs"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion crates/cpp_smoke_test/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern crate cpp_smoke_test;

use std::sync::atomic::{AtomicBool, Ordering};

extern "C" {
unsafe extern "C" {
fn cpp_trampoline(func: extern "C" fn()) -> ();
}

Expand Down
2 changes: 1 addition & 1 deletion crates/debuglink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "debuglink"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/dylib-dep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dylib-dep"
version = "0.1.0"
edition = "2021"
edition = "2024"
authors = []
publish = false

Expand Down
2 changes: 1 addition & 1 deletion crates/dylib-dep/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro_rules! pos {
};
}

#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn foo(outer: Pos, inner: fn(Pos, Pos)) {
inner(outer, pos!());
}
2 changes: 1 addition & 1 deletion crates/line-tables-only/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "line-tables-only"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/line-tables-only/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod tests {

pub type Callback = extern "C" fn(data: *mut c_void);

extern "C" {
unsafe extern "C" {
fn foo(cb: Callback, data: *mut c_void);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/macos_frames_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "macos_frames_test"
version = "0.1.0"
authors = ["Aaron Hill <[email protected]>"]
edition = "2021"
edition = "2024"
publish = false

[dependencies.backtrace]
Expand Down
2 changes: 1 addition & 1 deletion crates/without_debuginfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "without_debuginfo"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2021"
edition = "2024"
publish = false

[dependencies.backtrace]
Expand Down
4 changes: 2 additions & 2 deletions src/capture.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(clippy::from_over_into)]

use crate::PrintFmt;
#[cfg(feature = "serde")]
use crate::resolve;
use crate::PrintFmt;
use crate::{resolve_frame, trace, BacktraceFmt, Symbol, SymbolName};
use crate::{BacktraceFmt, Symbol, SymbolName, resolve_frame, trace};
use core::ffi::c_void;
use std::fmt;
use std::path::{Path, PathBuf};
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ extern crate std;
#[allow(unused_extern_crates)]
extern crate alloc;

pub use self::backtrace::{trace_unsynchronized, Frame};
pub use self::backtrace::{Frame, trace_unsynchronized};
mod backtrace;

pub use self::symbolize::resolve_frame_unsynchronized;
pub use self::symbolize::{resolve_unsynchronized, Symbol, SymbolName};
pub use self::symbolize::{Symbol, SymbolName, resolve_unsynchronized};
mod symbolize;

pub use self::types::BytesOrWideString;
Expand Down
5 changes: 3 additions & 2 deletions src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ impl<'a, 'b> BacktraceFmt<'a, 'b> {
pub fn new(
fmt: &'a mut fmt::Formatter<'b>,
format: PrintFmt,
print_path: &'a mut (dyn FnMut(&mut fmt::Formatter<'_>, BytesOrWideString<'_>) -> fmt::Result
+ 'b),
print_path: &'a mut (
dyn FnMut(&mut fmt::Formatter<'_>, BytesOrWideString<'_>) -> fmt::Result + 'b
),
) -> Self {
BacktraceFmt {
fmt,
Expand Down
4 changes: 2 additions & 2 deletions src/symbolize/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ unsafe fn do_resolve(
// the real value.
// SAFETY: We assume NameLen has been initialized by SymFromAddrW, and we initialized MaxNameLen
let name_len = unsafe { cmp::min((*info).NameLen as usize, (*info).MaxNameLen as usize - 1) };
// Name must be initialized by SymFromAddrW, but we only interact with it as a pointer anyways.
let name_ptr = (&raw const (*info).Name).cast::<u16>();
// SAFETY: Name must be initialized by SymFromAddrW, but we only interact with it as a pointer anyways.
let name_ptr = unsafe { (&raw const (*info).Name).cast::<u16>() };
Comment on lines +248 to +249
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this unsafe block during my post-push editing of #737 because I thought the compiler said it was superfluous, but now it is required for reasons that aren't clear to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wondered about that but I trusted the compiler to complain if it's not needed, ha.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may need to poke at this a bit more if it's an edition-based unsafety difference: that shouldn't really be the case. It could have just been human confusion on my end though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...I identified the diff in question removed deny(unsafe_op_in_unsafe_fn) as well as the unsafe block, so there is no edition-based problem aside from the lint being enabled or not.


// Reencode the utf-16 symbol to utf-8 so we can use `SymbolName::new` like
// all other platforms
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!
//! This is the default symbolication implementation for Rust.

use self::gimli::read::EndianSlice;
use self::gimli::NativeEndian as Endian;
use self::gimli::read::EndianSlice;
use self::mmap::Mmap;
use self::stash::Stash;
use super::BytesOrWideString;
Expand Down
6 changes: 3 additions & 3 deletions src/symbolize/gimli/coff.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::mystd::path::Path;
use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash};
use super::{Context, Endian, EndianSlice, Mapping, Stash, gimli};
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::convert::TryFrom;
use object::LittleEndian as LE;
use object::pe::{ImageDosHeader, ImageSymbol};
use object::read::StringTable;
use object::read::coff::ImageSymbol as _;
use object::read::pe::{ImageNtHeaders, ImageOptionalHeader, SectionTable};
use object::read::StringTable;
use object::LittleEndian as LE;

#[cfg(target_pointer_width = "32")]
type Pe = object::pe::ImageNtHeaders32;
Expand Down
12 changes: 6 additions & 6 deletions src/symbolize/gimli/elf.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#![allow(clippy::useless_conversion)]

use super::Either;
use super::mystd::ffi::OsStr;
use super::mystd::fs;
use super::mystd::os::unix::ffi::OsStrExt;
use super::mystd::path::{Path, PathBuf};
use super::Either;
use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash};
use super::{Context, Endian, EndianSlice, Mapping, Stash, gimli};
use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::convert::{TryFrom, TryInto};
use core::str;
#[cfg(feature = "ruzstd")]
use object::elf::ELFCOMPRESS_ZSTD;
use object::elf::{ELFCOMPRESS_ZLIB, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED};
use object::read::elf::{CompressionHeader, FileHeader, SectionHeader, SectionTable, Sym};
use object::elf::{ELF_NOTE_GNU, ELFCOMPRESS_ZLIB, NT_GNU_BUILD_ID, SHF_COMPRESSED};
use object::read::StringTable;
use object::read::elf::{CompressionHeader, FileHeader, SectionHeader, SectionTable, Sym};
use object::{BigEndian, Bytes, NativeEndian};

#[cfg(target_pointer_width = "32")]
Expand Down Expand Up @@ -340,11 +340,11 @@ impl<'a> Object<'a> {
}

fn decompress_zlib(input: &[u8], output: &mut [u8]) -> Option<()> {
use miniz_oxide::inflate::TINFLStatus;
use miniz_oxide::inflate::core::inflate_flags::{
TINFL_FLAG_PARSE_ZLIB_HEADER, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF,
};
use miniz_oxide::inflate::core::{decompress, DecompressorOxide};
use miniz_oxide::inflate::TINFLStatus;
use miniz_oxide::inflate::core::{DecompressorOxide, decompress};

let (status, in_read, out_read) = decompress(
&mut DecompressorOxide::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_aix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{Library, LibrarySegment};
use alloc::borrow::ToOwned;
use alloc::vec;
use alloc::vec::Vec;
use core::ffi::{c_int, CStr};
use core::ffi::{CStr, c_int};
use core::mem;

const EXE_IMAGE_BASE: u64 = 0x100000000;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_dl_iterate_phdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use super::mystd::env;
use super::mystd::ffi::{OsStr, OsString};
use super::mystd::os::unix::prelude::*;
use super::{parse_running_mmaps, Library, LibrarySegment};
use super::{Library, LibrarySegment, parse_running_mmaps};
use alloc::borrow::ToOwned;
use alloc::vec::Vec;
use core::ffi::CStr;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub(super) fn native_libraries() -> Vec<Library> {
}

fn native_library(i: u32) -> Option<Library> {
use object::NativeEndian;
use object::macho;
use object::read::macho::{MachHeader, Segment};
use object::NativeEndian;

// Fetch the name of this library which corresponds to the path of
// where to load it as well.
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/libs_windows.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::super::super::windows_sys::*;
use super::mystd::ffi::OsString;
use super::{coff, mmap, Library, LibrarySegment};
use super::{Library, LibrarySegment, coff, mmap};
use alloc::vec;
use alloc::vec::Vec;
use core::mem;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/macho.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::mystd::path::Path;
use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash};
use super::{Context, Endian, EndianSlice, Mapping, Stash, gimli};
use alloc::boxed::Box;
use alloc::sync::Arc;
use alloc::vec::Vec;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/mmap_fake.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::mystd::io::{Read, Seek, SeekFrom};
use super::File;
use super::mystd::io::{Read, Seek, SeekFrom};
use alloc::vec::Vec;
use core::ops::Deref;

Expand Down
6 changes: 3 additions & 3 deletions src/symbolize/gimli/xcoff.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use super::mystd::ffi::OsStr;
use super::mystd::os::unix::ffi::OsStrExt;
use super::mystd::path::Path;
use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash};
use super::{Context, Endian, EndianSlice, Mapping, Stash, gimli};
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::ops::Deref;
use core::str;
use object::read::archive::ArchiveFile;
use object::read::xcoff::{FileHeader, SectionHeader, XcoffFile, XcoffSymbol};
use object::Object as _;
use object::ObjectSection as _;
use object::ObjectSymbol as _;
use object::SymbolFlags;
use object::read::archive::ArchiveFile;
use object::read::xcoff::{FileHeader, SectionHeader, XcoffFile, XcoffSymbol};

#[cfg(target_pointer_width = "32")]
type Xcoff = object::xcoff::FileHeader32;
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/miri.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::ffi::c_void;
use core::marker::PhantomData;

use super::super::backtrace::miri::{resolve_addr, Frame};
use super::super::backtrace::miri::{Frame, resolve_addr};
use super::BytesOrWideString;
use super::{ResolveWhat, SymbolName};

Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cfg_if::cfg_if! {
use super::backtrace::Frame;
use super::types::BytesOrWideString;
use core::ffi::c_void;
use rustc_demangle::{try_demangle, Demangle};
use rustc_demangle::{Demangle, try_demangle};

/// Resolve an address to a symbol, passing the symbol to the specified
/// closure.
Expand Down
20 changes: 12 additions & 8 deletions tests/concurrent-panics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::env;
use std::panic;
use std::process::Command;
use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
use std::thread;

const PANICS: usize = 100;
Expand Down Expand Up @@ -45,20 +45,24 @@ fn parent() {
fn child() {
let done = Arc::new(AtomicBool::new(false));
let done2 = done.clone();
let a = thread::spawn(move || loop {
if done2.load(SeqCst) {
break format!("{:?}", backtrace::Backtrace::new());
let a = thread::spawn(move || {
loop {
if done2.load(SeqCst) {
break format!("{:?}", backtrace::Backtrace::new());
}
}
});

let threads = (0..THREADS)
.map(|_| {
thread::spawn(|| {
for _ in 0..PANICS {
assert!(panic::catch_unwind(|| {
panic!();
})
.is_err());
assert!(
panic::catch_unwind(|| {
panic!();
})
.is_err()
);
}
})
})
Expand Down
Loading