backtrace-labs / crashpad

A fork of Crashpad with file attachment support and other improvements.
Apache License 2.0
99 stars 33 forks source link

Unable to Properly Save Dump Files on Windows #58

Open weypro opened 9 months ago

weypro commented 9 months ago

Hello. I have attempted to compile the CMake-wrapped version of Crashpad provided by Backtrace separately on Windows, aiming to retrieve and save dump files locally. I do not require the use of remote upload services. While the Windows demo can run, it consistently gets stuck at an unknown point and cannot proceed further. If I forcibly terminate the process, it does save a file, but the saved file is 0kb in size. In contrast, when using the crashpad provided by Sentry with the same examples, it executes successfully and the dump file is saved properly. Moreover, the program returns directly without any freezing issues. I suspect that the issue might be related to the handling of network connectivity, so I registered a Backtrace account and entered the URL parameters. However, even with this, the Backtrace handle still does not operate correctly. Interestingly, when I simply change the handle path to Sentry's while keeping the client as Backtrace's, it successfully uploads the dump file.

weypro commented 9 months ago

demo: https://github.com/backtrace-labs/crashpad/blob/backtrace/examples/windows/demo/demo.cpp My cmakelists:

cmake_minimum_required(VERSION 3.26)
project(crashpadtest)

set(CMAKE_CXX_STANDARD 17)

add_subdirectory(crashpad)

add_executable(crashpadtest main.cpp)
#target_link_libraries(crashpadtest PRIVATE crashpad_client)
target_link_libraries(crashpadtest PRIVATE client)
target_compile_definitions(crashpadtest PRIVATE
        NOMINMAX
        UNICODE
        WIN32_LEAN_AND_MEAN
        _CRT_SECURE_NO_WARNINGS
        _UNICODE
)
gm4sl commented 9 months ago

@weypro Could you please build the handler in a release configuration or, alternatively, comment out the following assertion in minidump/minidump_context_writer.cc and let us know if that helps. Thanks for the report and apologies for the trouble.


bool MinidumpXSaveAMD64CetU::InitializeFromSnapshot(
   const CPUContextX86_64* context_snapshot) {
   // NOTE(backtrace): the CET is zero'd out in exception_snapshot_win.cc and
   // the model specific register will never be set. Disabling the DCHECK to
   // prevent a fatal crash (invokes INT3).
   // DCHECK_EQ(context_snapshot->xstate.cet_u.cetmsr, 1ull);
   cet_u_.cetmsr = context_snapshot->xstate.cet_u.cetmsr;
   cet_u_.ssp = context_snapshot->xstate.cet_u.ssp;
   return true;
}