Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 4 additions & 2 deletions crates/symbolicator-native/src/symbolication/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::pin::pin;

use futures::TryStreamExt;
use symbolicator_service::download::DownloadService;
use tokio::io::{AsyncWriteExt, BufWriter};
use tokio::io::{AsyncSeekExt, AsyncWriteExt, BufWriter};
use tokio_util::io::StreamReader;

use crate::interface::AttachmentFile;
Expand Down Expand Up @@ -41,8 +41,10 @@ pub async fn download_attachment(
let mut writer = BufWriter::new(tokio::fs::File::from_std(file));
tokio::io::copy(&mut reader, &mut writer).await?;
writer.flush().await?;
let file = writer.into_inner();
let mut file = writer.into_inner();
file.sync_data().await?;

file.rewind().await?;

Ok(file.into_std().await)
}
1 change: 1 addition & 0 deletions crates/symbolicator-native/tests/integration/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// See <https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html>

pub mod e2e;
pub mod process_apple;
pub mod process_minidump;
pub mod public_sources;
pub mod source_errors;
Expand Down
42 changes: 42 additions & 0 deletions crates/symbolicator-native/tests/integration/process_apple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::sync::Arc;

use axum::Router;
use axum::http::header;
use axum::response::IntoResponse;
use axum::routing::get;
use symbolicator_test::Server;

use symbolicator_native::interface::AttachmentFile;
use symbolicator_service::types::Scope;

use crate::{assert_snapshot, read_fixture, setup_service, symbol_server};

#[tokio::test]
async fn test_attachment_download() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's a similar test in process_minidump.rs, but apple crash report downloads had no test coverage.

Without the fix in attachments.rs, this test fails with the same empty stack trace as we saw in #1884.

let (symbolication, _cache_dir) = setup_service(|_| ());
let (_symsrv, source) = symbol_server();

async fn get_crash_report() -> impl IntoResponse {
let report = read_fixture("apple_crash_report.txt");
let compressed = zstd::bulk::compress(&report, 0).unwrap();

([(header::CONTENT_ENCODING, "zstd")], compressed)
}
let router = Router::new().route("/the_crash_report.txt", get(get_crash_report));
let attachment_server = Server::with_router(router);

let response = symbolication
.process_apple_crash_report(
None,
Scope::Global,
AttachmentFile::Remote {
storage_url: attachment_server.url("/the_crash_report.txt").to_string(),
storage_token: None,
},
Arc::new([source]),
Default::default(),
)
.await;

assert_snapshot!(response.unwrap());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
---
source: crates/symbolicator-native/tests/integration/process_apple.rs
expression: response.unwrap()
---
timestamp: 1547055742
system_info:
os_name: macOS
os_version: 10.14.0
os_build: 18A391
cpu_arch: x86_64
device_model: "MacBookPro14,3"
crashed: true
crash_reason: SIGSEGV
crash_details: "objc_msgSend() selector name: respondsToSelector:\n more information here"
stacktraces:
- thread_id: 0
is_requesting: false
frames:
- status: unknown_image
original_index: 0
instruction_addr: "0x7fff61bc6c2a"
package: libsystem_kernel.dylib
- status: unknown_image
original_index: 1
instruction_addr: "0x7fff349f505e"
package: CoreFoundation
- status: unknown_image
original_index: 2
instruction_addr: "0x7fff349f45ad"
package: CoreFoundation
- status: unknown_image
original_index: 3
instruction_addr: "0x7fff349f3ce4"
package: CoreFoundation
- status: unknown_image
original_index: 4
instruction_addr: "0x7fff33c8d895"
package: HIToolbox
- status: unknown_image
original_index: 5
instruction_addr: "0x7fff33c8d5cb"
package: HIToolbox
- status: unknown_image
original_index: 6
instruction_addr: "0x7fff33c8d348"
package: HIToolbox
- status: unknown_image
original_index: 7
instruction_addr: "0x7fff31f4a95b"
package: AppKit
- status: unknown_image
original_index: 8
instruction_addr: "0x7fff31f496fa"
package: AppKit
- status: unknown_image
original_index: 9
instruction_addr: "0x7fff31f4375d"
package: AppKit
- status: missing
original_index: 10
instruction_addr: "0x108b7092b"
package: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/MacOS/YetAnotherMac
- status: missing
original_index: 11
instruction_addr: "0x108b702a6"
package: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/MacOS/YetAnotherMac
- status: unknown_image
original_index: 12
instruction_addr: "0x7fff61a8e085"
package: libdyld.dylib
- status: unknown_image
original_index: 13
instruction_addr: "0xea004"
package: YetanotherMac
- thread_id: 1
thread_name: Test Thread Name
is_requesting: true
registers:
cs: "0x2b"
fs: "0x0"
gs: "0x0"
r10: "0x0"
r11: "0xffffffff"
r12: "0x8"
r13: "0x11e800b00"
r14: "0x1"
r15: "0x0"
r8: "0x3"
r9: "0x10"
rax: "0x20261bb4775b008f"
rbp: "0x700015a616d0"
rbx: "0x0"
rcx: "0x1288266c0"
rdi: "0x0"
rdx: "0x1"
rflags: "0x10206"
rip: "0x1090a0132"
rsi: "0x0"
rsp: "0x700015a613f0"
frames:
- status: unknown_image
original_index: 0
instruction_addr: "0x7fff61bc85be"
package: libsystem_kernel.dylib
- status: unknown_image
original_index: 1
instruction_addr: "0x7fff61c7f415"
package: libsystem_pthread.dylib
- status: unknown_image
original_index: 2
instruction_addr: "0x54485244"
modules:
- debug_status: missing
features:
has_debug_info: false
has_unwind_info: false
has_symbols: false
has_sources: false
arch: unknown
type: macho
code_id: 2d903291397d3d14bfca52c7fb8c5e00
code_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/MacOS/YetAnotherMac
debug_id: 2d903291-397d-3d14-bfca-52c7fb8c5e00
debug_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/MacOS/YetAnotherMac
image_addr: "0x10864e000"
image_size: 108797951
candidates:
- source: local
location: "http://localhost:<port>/symbols/2D90/3291/397D/3D14/BFCA/52C7FB8C5E00"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/2D90/3291/397D/3D14/BFCA/52C7FB8C5E00.app"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/2D90/3291/397D/3D14/BFCA/52C7FB8C5E00.src.zip"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/2d/903291397d3d14bfca52c7fb8c5e00.debug"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/YetAnotherMac/2D903291397D3D14BFCA52C7FB8C5E000/YetAnotherMa_"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/YetAnotherMac/2D903291397D3D14BFCA52C7FB8C5E000/YetAnotherMac"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/YetAnotherMac/2D903291397D3D14BFCA52C7FB8C5E000/YetAnotherMac.src.zip"
download:
status: notfound
- source: local
location: "http://localhost:<port>/symbols/YetAnotherMac/2D903291397D3D14BFCA52C7FB8C5E000/YetAnotherMac.sym"
download:
status: notfound
- debug_status: unused
features:
has_debug_info: false
has_unwind_info: false
has_symbols: false
has_sources: false
arch: unknown
type: macho
code_id: 6deccee4a0523ea4bb67957b06f53ad1
code_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3PROFILE.dylib
debug_id: 6deccee4-a052-3ea4-bb67-957b06f53ad1
debug_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3PROFILE.dylib
image_addr: "0x112bb2000"
image_size: 2170879
- debug_status: unused
features:
has_debug_info: false
has_unwind_info: false
has_symbols: false
has_sources: false
arch: unknown
type: macho
code_id: 5e012a646cc536f19b4da0564049169b
code_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3CookingPROFILE.dylib
debug_id: 5e012a64-6cc5-36f1-9b4d-a0564049169b
debug_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3CookingPROFILE.dylib
image_addr: "0x112fc0000"
image_size: 221183
- debug_status: unused
features:
has_debug_info: false
has_unwind_info: false
has_symbols: false
has_sources: false
arch: unknown
type: macho
code_id: 9c19854471943de6b67e4cc27eed2eab
code_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3CommonPROFILE.dylib
debug_id: 9c198544-7194-3de6-b67e-4cc27eed2eab
debug_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPhysX3CommonPROFILE.dylib
image_addr: "0x113013000"
image_size: 1474559
- debug_status: unused
features:
has_debug_info: false
has_unwind_info: false
has_symbols: false
has_sources: false
arch: unknown
type: macho
code_id: 890f0997f90435449af7cf011f09a06e
code_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPxFoundationPROFILE.dylib
debug_id: 890f0997-f904-3544-9af7-cf011f09a06e
debug_file: /Users/bruno/Documents/Unreal Projects/YetAnotherMac/MacNoEditor/YetAnotherMac.app/Contents/UE4/Engine/Binaries/ThirdParty/PhysX3/Mac/libPxFoundationPROFILE.dylib
image_addr: "0x1131fa000"
image_size: 28671
Loading