@@ -127,8 +127,11 @@ write_data(minidump_writer_t *writer, const void *data, size_t size)
127127 uint32_t padding = (4 - (writer -> current_offset % 4 )) % 4 ;
128128 if (padding > 0 ) {
129129 const uint8_t zeros [4 ] = { 0 };
130- write (writer -> fd , zeros , padding );
131- writer -> current_offset += padding ;
130+ if (write (writer -> fd , zeros , padding ) == (ssize_t )padding ) {
131+ writer -> current_offset += padding ;
132+ }
133+ // On padding write failure, don't update offset - RVA is still valid
134+ // for the data that was written
132135 }
133136
134137 return rva ;
@@ -799,18 +802,14 @@ write_exception_stream(minidump_writer_t *writer, minidump_directory_t *dir)
799802 = (uint64_t )writer -> crash_ctx -> platform .siginfo .si_addr ;
800803 exception_stream .exception_record .number_parameters = 0 ;
801804
802- // Write the crashing thread's context
803- // Use the context from the first thread in the crash context (the crashing
804- // thread)
805- if (writer -> crash_ctx -> platform .num_threads > 0 ) {
806- const _STRUCT_MCONTEXT * crash_state
807- = & writer -> crash_ctx -> platform .threads [0 ].state ;
808- exception_stream .thread_context .rva
809- = write_thread_context (writer , crash_state );
810- exception_stream .thread_context .size = get_context_size ();
811- SENTRY_DEBUGF ("Exception: wrote context at RVA 0x%x for thread %u" ,
812- exception_stream .thread_context .rva , exception_stream .thread_id );
813- }
805+ // Write the crashing thread's context using the dedicated mcontext field
806+ // (consistent with Linux which uses platform.context)
807+ const _STRUCT_MCONTEXT * crash_state = & writer -> crash_ctx -> platform .mcontext ;
808+ exception_stream .thread_context .rva
809+ = write_thread_context (writer , crash_state );
810+ exception_stream .thread_context .size = get_context_size ();
811+ SENTRY_DEBUGF ("Exception: wrote context at RVA 0x%x for thread %u" ,
812+ exception_stream .thread_context .rva , exception_stream .thread_id );
814813
815814 dir -> stream_type = MINIDUMP_STREAM_EXCEPTION ;
816815 dir -> rva = write_data (writer , & exception_stream , sizeof (exception_stream ));
@@ -1200,7 +1199,9 @@ sentry__write_minidump(
12001199 enumerate_memory_regions (& writer );
12011200
12021201 // Reserve space for header and directory
1203- const uint32_t stream_count = 3 ; // system_info, threads, exception
1202+ // Write 5 streams: system_info, threads, exception, module_list,
1203+ // memory_list
1204+ const uint32_t stream_count = 5 ;
12041205 writer .current_offset = sizeof (minidump_header_t )
12051206 + (stream_count * sizeof (minidump_directory_t ));
12061207
@@ -1209,12 +1210,14 @@ sentry__write_minidump(
12091210 }
12101211
12111212 // Write streams
1212- minidump_directory_t directories [3 ];
1213+ minidump_directory_t directories [5 ];
12131214 int result = 0 ;
12141215
12151216 result |= write_system_info_stream (& writer , & directories [0 ]);
12161217 result |= write_thread_list_stream (& writer , & directories [1 ]);
12171218 result |= write_exception_stream (& writer , & directories [2 ]);
1219+ result |= write_module_list_stream (& writer , & directories [3 ]);
1220+ result |= write_memory_list_stream (& writer , & directories [4 ]);
12181221
12191222 if (result < 0 ) {
12201223 goto cleanup_error ;
0 commit comments