Skip to content

Commit

Permalink
Merge branch 'main' into bob/multitarget-race
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi authored Feb 14, 2025
2 parents d491cea + 958830a commit 859332c
Show file tree
Hide file tree
Showing 17 changed files with 620 additions and 234 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ resolver = "2"
[workspace.package]
rust-version = "1.78.0"
edition = "2021"
version = "16.0.2"
version = "16.0.3"
license = "Apache-2.0"

[profile.dev]
Expand All @@ -73,6 +73,12 @@ opt-level = "s" # optimize for size
[profile.release.package.datadog-serverless-trace-mini-agent]
strip = true

[profile.bench]
codegen-units = 1
debug = false
incremental = false
opt-level = 3

# https://camshaft.github.io/bolero/library-installation.html
[profile.fuzz]
inherits = "dev"
Expand Down
19 changes: 15 additions & 4 deletions bin_tests/src/bin/crashtracker_bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn main() -> anyhow::Result<()> {
mod unix {
use anyhow::Context;
use bin_tests::modes::behavior::get_behavior;
use nix::sys::signal::{raise, Signal};
use std::env;
use std::path::Path;

Expand All @@ -24,8 +25,9 @@ mod unix {
const TEST_COLLECTOR_TIMEOUT_MS: u32 = 10_000;

#[inline(never)]
unsafe fn deref_ptr(p: *mut u8) {
unsafe fn deref_ptr(p: *mut u8) -> u8 {
*std::hint::black_box(p) = std::hint::black_box(1);
*std::hint::black_box(p)
}

pub fn main() -> anyhow::Result<()> {
Expand All @@ -34,6 +36,7 @@ mod unix {
let receiver_binary = args.next().context("Unexpected number of arguments")?;
let output_dir = args.next().context("Unexpected number of arguments")?;
let mode_str = args.next().context("Unexpected number of arguments")?;
let crash_typ = args.next().context("Missing crash type")?;
anyhow::ensure!(args.next().is_none(), "unexpected extra arguments");

let stderr_filename = format!("{output_dir}/out.stderr");
Expand All @@ -54,6 +57,7 @@ mod unix {
create_alt_stack: true,
use_alt_stack: true,
resolve_frames: crashtracker::StacktraceCollection::WithoutSymbols,
signals: crashtracker::default_signals(),
endpoint,
timeout_ms: TEST_COLLECTOR_TIMEOUT_MS,
unix_socket_path: Some("".to_string()),
Expand Down Expand Up @@ -95,11 +99,18 @@ mod unix {
behavior.post(output_dir)?;

crashtracker::begin_op(crashtracker::OpTypes::ProfilerCollectingSample)?;
unsafe {
deref_ptr(std::ptr::null_mut::<u8>());
match crash_typ.as_str() {
"null_deref" => {
let x = unsafe { deref_ptr(std::ptr::null_mut::<u8>()) };
println!("{x}");
}
"sigabrt" => raise(Signal::SIGABRT)?,
"sigill" => raise(Signal::SIGILL)?,
"sigbus" => raise(Signal::SIGBUS)?,
"sigsegv" => raise(Signal::SIGSEGV)?,
_ => anyhow::bail!("Unexpected crash_typ: {crash_typ}"),
}
crashtracker::end_op(crashtracker::OpTypes::ProfilerCollectingSample)?;

Ok(())
}
}
Loading

0 comments on commit 859332c

Please sign in to comment.