Author: Alvin Wong Date: 2022-06-22T17:16:06+03:00 New Revision: 4d123783957e547009e55346bf3a8ae43a88fa14
URL: https://github.com/llvm/llvm-project/commit/4d123783957e547009e55346bf3a8ae43a88fa14 DIFF: https://github.com/llvm/llvm-project/commit/4d123783957e547009e55346bf3a8ae43a88fa14.diff LOG: [lldb][windows] Fix crash on getting nested exception LLDB tries to follow `EXCEPTION_RECORD::ExceptionRecord` to follow the nested exception chain. In practice this code just causes Access Violation whenever there is a nested exception. Since there does not appear to be any code in LLDB that is actually using the nested exceptions, this change just removes the crashing code and adds a comment for future reference. Fixes https://github.com/mstorsjo/llvm-mingw/issues/292 Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D128201 Added: Modified: lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h b/lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h index d1692a6926b2..4499698369f5 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h +++ b/lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h @@ -25,11 +25,17 @@ namespace lldb_private { class ExceptionRecord { public: ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) { + // Notes about the `record.ExceptionRecord` field: + // In the past, some code tried to parse the nested exception with it, but + // in practice, that code just causes Access Violation. I suspect + // `ExceptionRecord` here actually points to the address space of the + // debuggee process. However, I did not manage to find any official or + // unofficial reference that clarifies this point. If anyone would like to + // reimplement this, please also keep in mind to check how this behaves when + // debugging a WOW64 process. I suspect you may have to use the explicit + // `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs. m_code = record.ExceptionCode; m_continuable = (record.ExceptionFlags == 0); - if (record.ExceptionRecord) - m_next_exception.reset( - new ExceptionRecord(*record.ExceptionRecord, thread_id)); m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress); m_thread_id = thread_id; m_arguments.assign(record.ExceptionInformation, @@ -39,27 +45,16 @@ class ExceptionRecord { // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs. ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id) : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0), - m_next_exception(nullptr), m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)), m_thread_id(thread_id), m_arguments(record.ExceptionInformation, - record.ExceptionInformation + record.NumberParameters) { - // Set up link to nested exception. - if (record.ExceptionRecord) { - m_next_exception.reset(new ExceptionRecord( - *reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord), - thread_id)); - } - } + record.ExceptionInformation + record.NumberParameters) {} virtual ~ExceptionRecord() {} DWORD GetExceptionCode() const { return m_code; } bool IsContinuable() const { return m_continuable; } - const ExceptionRecord *GetNextException() const { - return m_next_exception.get(); - } lldb::addr_t GetExceptionAddress() const { return m_exception_addr; } lldb::tid_t GetThreadID() const { return m_thread_id; } @@ -69,7 +64,6 @@ class ExceptionRecord { private: DWORD m_code; bool m_continuable; - std::shared_ptr<ExceptionRecord> m_next_exception; lldb::addr_t m_exception_addr; lldb::tid_t m_thread_id; std::vector<ULONG_PTR> m_arguments; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits