Skip to content

Commit 6fca3dd

Browse files
committed
Fixes
1 parent c5d4fda commit 6fca3dd

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/backends/native/minidump/sentry_minidump_format.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,19 @@ PACKED_STRUCT_END
476476
/**
477477
* Linux DSO debug structures (MD_LINUX_DSO_DEBUG, 0x4767000A)
478478
*
479-
* Mirrors Breakpad's MDRawLinkMap64 / MDRawDebug64. LLDB and rust-minidump
480-
* use this stream to enumerate loaded shared objects when LinuxAuxv alone
481-
* isn't enough (e.g. modules loaded via dlopen after process startup that
482-
* aren't in /proc/<pid>/maps in a usable order).
479+
* Wire-compatible with Breakpad's MDRawLinkMap64 / MDRawDebug64. Breakpad
480+
* builds these under `#pragma pack(push, 4)`, so a uint64_t can sit on a
481+
* 4-byte boundary with no padding inserted between the preceding uint32_t
482+
* and itself. We use PACKED_ATTR (== __attribute__((packed))) to get the
483+
* same byte-exact layout: 20 bytes for link_map64, 36 bytes for debug64.
484+
*
485+
* Adding explicit _pad fields here would break the layout — LLDB and
486+
* rust-minidump compute offsets assuming the Breakpad sizes.
483487
*/
484488
PACKED_STRUCT_BEGIN
485489
typedef struct {
486490
uint64_t addr; // l_addr from struct link_map
487491
minidump_rva_t name; // RVA to MINIDUMP_STRING with the SO path
488-
uint32_t _pad;
489492
uint64_t ld; // l_ld from struct link_map (PT_DYNAMIC of this DSO)
490493
} PACKED_ATTR minidump_link_map64_t;
491494
PACKED_STRUCT_END
@@ -495,7 +498,6 @@ typedef struct {
495498
uint32_t version; // r_debug.r_version
496499
minidump_rva_t map; // RVA to array of minidump_link_map64_t
497500
uint32_t dso_count; // number of entries in map
498-
uint32_t _pad;
499501
uint64_t brk; // r_debug.r_brk
500502
uint64_t ldbase; // r_debug.r_ldbase
501503
uint64_t dynamic; // address of the program's _DYNAMIC section

src/backends/native/minidump/sentry_minidump_linux.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,8 +2874,10 @@ sentry__write_minidump(
28742874
minidump_writer_t writer = { 0 };
28752875
writer.crash_ctx = ctx;
28762876

2877-
// Open output file
2878-
writer.fd = open(output_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
2877+
// Open output file. O_RDWR (not O_WRONLY) because SMART-mode indirect
2878+
// memory capture pread()'s thread-stack bytes back from the dump after
2879+
// they're written, so it can scan them for heap pointers.
2880+
writer.fd = open(output_path, O_RDWR | O_CREAT | O_TRUNC, 0600);
28792881
if (writer.fd < 0) {
28802882
SENTRY_WARNF("failed to create minidump: %s", strerror(errno));
28812883
return -1;

src/backends/native/minidump/sentry_minidump_macos.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,9 +1378,11 @@ sentry__write_minidump(
13781378
minidump_writer_t writer = { 0 };
13791379
writer.crash_ctx = ctx;
13801380

1381-
// Open output file
1381+
// Open output file. O_RDWR (not O_WRONLY) because SMART-mode indirect
1382+
// memory capture pread()'s thread-stack bytes back from the dump after
1383+
// they're written, so it can scan them for heap pointers.
13821384
SENTRY_DEBUGF("write_minidump: opening file %s", output_path);
1383-
writer.fd = open(output_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
1385+
writer.fd = open(output_path, O_RDWR | O_CREAT | O_TRUNC, 0600);
13841386
if (writer.fd < 0) {
13851387
SENTRY_WARN("write_minidump: failed to open file");
13861388
return -1;

0 commit comments

Comments
 (0)