Skip to content
Open
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
51 changes: 44 additions & 7 deletions bin_tests/tests/crashtracker_bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,40 @@ fn test_crash_tracking_bin_runtime_callback_frame() {
run_crash_test_with_artifacts(&config, &artifacts_map, &artifacts, validator).unwrap();
}

#[test]
#[cfg(target_os = "linux")]
#[cfg_attr(miri, ignore)]
fn test_crash_tracking_thread_name() {
let config = CrashTestConfig::new(
BuildProfile::Release,
TestMode::DoNothing,
CrashType::NullDeref,
);
let artifacts = StandardArtifacts::new(config.profile);
let artifacts_map = build_artifacts(&artifacts.as_slice()).unwrap();

let validator: ValidatorFn = Box::new(|payload, _fixtures| {
let error = &payload["error"];
let thread_name = error["thread_name"]
.as_str()
.expect("thread_name should be present");
assert!(
!thread_name.trim().is_empty(),
"thread_name should not be empty: {thread_name:?}"
);
assert!(
// Cutting `crashtracker_bin_test` to `crashtracker_bin` because linux
// thread name is limited to 15 characters
thread_name.contains("crashtracker_bi"),
"thread_name should contain binary name: {thread_name:?}"
);

Ok(())
});

run_crash_test_with_artifacts(&config, &artifacts_map, &artifacts, validator).unwrap();
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_crash_tracking_bin_runtime_callback_string() {
Expand Down Expand Up @@ -1045,17 +1079,20 @@ fn assert_telemetry_message(crash_telemetry: &[u8], crash_typ: &str) {
let tags = tags_raw
.split(',')
.filter(|t| !t.starts_with("uuid:"))
.map(|t| t.to_string())
.collect::<std::collections::HashSet<_>>();

let base_expected_tags: std::collections::HashSet<&str> =
let current_schema_version = libdd_crashtracker::CrashInfo::current_schema_version();

let base_expected_tags: std::collections::HashSet<String> =
std::collections::HashSet::from_iter([
"data_schema_version:1.4",
format!("data_schema_version:{current_schema_version}"),
// "incomplete:false", // TODO: re-add after fixing musl unwinding
"is_crash:true",
"profiler_collecting_sample:1",
"profiler_inactive:0",
"profiler_serializing:0",
"profiler_unwinding:0",
"is_crash:true".to_string(),
"profiler_collecting_sample:1".to_string(),
"profiler_inactive:0".to_string(),
"profiler_serializing:0".to_string(),
"profiler_unwinding:0".to_string(),
]);

match crash_typ {
Expand Down
13 changes: 12 additions & 1 deletion docs/RFCs/0011-crashtracker-structured-log-format-V1_X.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Consumers of the crash data format SHOULD be designed to handle all versions fro
- `stack`: **[required]**
This represents the stack of the crashing thread.
See below for more details on how stacktraces are formatted.
- `thread_name`: **[optional]**
Name of the crashing thread
- `files`: **[optional]**
A `Map<filename, contents>` where `contents` is an array of plain text strings, one per line.
Useful files for triage and debugging, such as `/proc/self/maps` or `/proc/meminfo`.
Expand Down Expand Up @@ -273,6 +275,15 @@ This section documents the evolution of the crashtracker structured log format a

**Motivation:** When symbol names are demangled for readability, the original mangled names are lost. This makes debugging difficult when mangled names are needed (e.g., comparing against compiler-generated symbols). The `mangled_name` field preserves the original mangled name when demangling occurs.

### Version 1.5
*Added thread_name to `ErrorData`

**Changes from v1.4:**
- Added `thread_name` field to `Error` objects (optional string)
- Updated `data_schema_version` to "1.5"

**Motivation:** Having access to thread name of the crashing thread helps debugging, especially within multithreaded programs.

## Appendix A: Example output

An example crash report in version 1.0 format is [available here](artifacts/0005-crashtracker-example.json).
Expand All @@ -281,7 +292,7 @@ Note: This example uses version 1.0 format. Version 1.1+ may include additional

## Appendix B: Json Schema

The current JSON schema (version 1.4) is [available here](artifacts/0009-crashtracker-schema.json).
The current JSON schema (version 1.5) is [available here](artifacts/crashtracker-unified-runtime-stack-schema-v1_5.json).

Historical schemas are also available:
- [Version 1.0 schema](artifacts/0005-crashtracker-schema.json)
Expand Down
Loading
Loading