From fd4fd78dd932a8e318a74ddcd3632e948b1fa69a Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Thu, 12 Oct 2023 11:43:30 +0200 Subject: [PATCH 1/6] Collect /proc/self/limits on Linux --- .cargo/config.toml | 9 +++++++++ Cargo.toml | 2 +- src/linux/minidump_writer.rs | 11 +++++++++++ tests/linux_minidump_writer.rs | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..ee2e20ca --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'] +rustflags = [ + "-C", + "link-arg=-fuse-ld=lld", + # LLD by default uses xxhash for build ids now, which breaks tests that assume + # GUIDS or longer + "-C", + "link-arg=-Wl,--build-id=sha1", +] diff --git a/Cargo.toml b/Cargo.toml index cbe887c4..889d8d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ byteorder = "1.4" cfg-if = "1.0" crash-context = "0.6" memoffset = "0.9" -minidump-common = "0.19" +minidump-common = "0.19.1" scroll = "0.11" tempfile = "3.8" thiserror = "1.0" diff --git a/src/linux/minidump_writer.rs b/src/linux/minidump_writer.rs index 7be6cef9..bbe1dec9 100644 --- a/src/linux/minidump_writer.rs +++ b/src/linux/minidump_writer.rs @@ -323,6 +323,17 @@ impl MinidumpWriter { // Write section to file dir_section.write_to_file(buffer, Some(dirent))?; + let dirent = match self.write_file(buffer, &format!("/proc/{}/limits", self.blamed_thread)) + { + Ok(location) => MDRawDirectory { + stream_type: MDStreamType::MozLinuxLimits as u32, + location, + }, + Err(_) => Default::default(), + }; + // Write section to file + dir_section.write_to_file(buffer, Some(dirent))?; + let dirent = thread_names_stream::write(buffer, dumper)?; // Write section to file dir_section.write_to_file(buffer, Some(dirent))?; diff --git a/tests/linux_minidump_writer.rs b/tests/linux_minidump_writer.rs index 8552003e..d9864bae 100644 --- a/tests/linux_minidump_writer.rs +++ b/tests/linux_minidump_writer.rs @@ -224,6 +224,9 @@ contextual_tests! { let _ = dump .get_raw_stream(LinuxDsoDebug as u32) .expect("Couldn't find LinuxDsoDebug"); + let _ = dump + .get_raw_stream(MozLinuxLimits as u32) + .expect("Couldn't find MozLinuxLimits"); } fn test_write_with_additional_memory(context: Context) { From 0c6d43f741236e871bc390dc1e067abe149e683c Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 13 Oct 2023 10:22:27 +0200 Subject: [PATCH 2/6] Keep config but commented out --- .cargo/config.toml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ee2e20ca..cc393889 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,9 +1,11 @@ -[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'] -rustflags = [ - "-C", - "link-arg=-fuse-ld=lld", - # LLD by default uses xxhash for build ids now, which breaks tests that assume - # GUIDS or longer - "-C", - "link-arg=-Wl,--build-id=sha1", -] +# If you have a global config to use LLD on your machine, you might need to enable +# this config to produce binaries that pass tests +# [target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'] +# rustflags = [ +# "-C", +# "link-arg=-fuse-ld=lld", +# # LLD by default uses xxhash for build ids now, which breaks tests that assume +# # GUIDS or longer +# "-C", +# "link-arg=-Wl,--build-id=sha1", +# ] From 36a8c433816a3904e9b48f7a7154071354f19175 Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Thu, 12 Oct 2023 16:39:16 +0200 Subject: [PATCH 3/6] WIP: Use nix=0.26 to make mach build happy --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 889d8d9a..e44141b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ goblin = "0.7.1" memmap2 = "0.8" [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] -nix = { version = "0.27", default-features = false, features = [ +nix = { version = "0.26", default-features = false, features = [ "mman", "process", "ptrace", From d4a8a8318bfff19f19a15aefbf134c8702a30ea1 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 13 Oct 2023 09:39:41 +0200 Subject: [PATCH 4/6] Fix build --- Cargo.toml | 5 ++++- deny.toml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e44141b1..63b944d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ goblin = "0.7.1" memmap2 = "0.8" [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] -nix = { version = "0.26", default-features = false, features = [ +nix = { version = "0.27", default-features = false, features = [ "mman", "process", "ptrace", @@ -56,3 +56,6 @@ minidump-processor = { version = "0.19", default-features = false } minidump-unwind = { version = "0.19", features = ["debuginfo"] } similar-asserts = "1.5" uuid = "1.4" + +[patch.crates-io] +minidump-common = { git = "https://github.com/lissyx/rust-minidump.git", rev = "2f996932695d8355a8609f2a8744c01b8b034d39" } diff --git a/deny.toml b/deny.toml index 3cadd53b..fee73e4e 100644 --- a/deny.toml +++ b/deny.toml @@ -16,6 +16,8 @@ multiple-versions = "deny" skip = [ # scroll still depends on 1.0 { name = "syn", version = "=1.0.109" }, + # many crates still depend on old version + { name = "bitflags", version = "=1.3.2" }, ] [licenses] From 908190fe3d8b39962746502e78679b82ea68021b Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 6 Nov 2023 20:36:30 +0100 Subject: [PATCH 5/6] Fixup deny --- Cargo.toml | 3 --- deny.toml | 2 -- 2 files changed, 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 63b944d2..889d8d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,3 @@ minidump-processor = { version = "0.19", default-features = false } minidump-unwind = { version = "0.19", features = ["debuginfo"] } similar-asserts = "1.5" uuid = "1.4" - -[patch.crates-io] -minidump-common = { git = "https://github.com/lissyx/rust-minidump.git", rev = "2f996932695d8355a8609f2a8744c01b8b034d39" } diff --git a/deny.toml b/deny.toml index fee73e4e..3cadd53b 100644 --- a/deny.toml +++ b/deny.toml @@ -16,8 +16,6 @@ multiple-versions = "deny" skip = [ # scroll still depends on 1.0 { name = "syn", version = "=1.0.109" }, - # many crates still depend on old version - { name = "bitflags", version = "=1.3.2" }, ] [licenses] From 1377816788d82165fd84cade45983c63ca2ed7f9 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 6 Nov 2023 20:45:09 +0100 Subject: [PATCH 6/6] Bump stream count --- src/linux/minidump_writer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux/minidump_writer.rs b/src/linux/minidump_writer.rs index bbe1dec9..da395b53 100644 --- a/src/linux/minidump_writer.rs +++ b/src/linux/minidump_writer.rs @@ -189,7 +189,7 @@ impl MinidumpWriter { ) -> Result<()> { // A minidump file contains a number of tagged streams. This is the number // of streams which we write. - let num_writers = 16u32; + let num_writers = 17u32; let mut header_section = MemoryWriter::::alloc(buffer)?;