Skip to content

Commit 4d12378

Browse files
alvinhochunmstorsjo
authored andcommitted
[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 mstorsjo/llvm-mingw#292 Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D128201
1 parent 2bae956 commit 4d12378

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ namespace lldb_private {
2525
class ExceptionRecord {
2626
public:
2727
ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
28+
// Notes about the `record.ExceptionRecord` field:
29+
// In the past, some code tried to parse the nested exception with it, but
30+
// in practice, that code just causes Access Violation. I suspect
31+
// `ExceptionRecord` here actually points to the address space of the
32+
// debuggee process. However, I did not manage to find any official or
33+
// unofficial reference that clarifies this point. If anyone would like to
34+
// reimplement this, please also keep in mind to check how this behaves when
35+
// debugging a WOW64 process. I suspect you may have to use the explicit
36+
// `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
2837
m_code = record.ExceptionCode;
2938
m_continuable = (record.ExceptionFlags == 0);
30-
if (record.ExceptionRecord)
31-
m_next_exception.reset(
32-
new ExceptionRecord(*record.ExceptionRecord, thread_id));
3339
m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
3440
m_thread_id = thread_id;
3541
m_arguments.assign(record.ExceptionInformation,
@@ -39,27 +45,16 @@ class ExceptionRecord {
3945
// MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
4046
ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
4147
: m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
42-
m_next_exception(nullptr),
4348
m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)),
4449
m_thread_id(thread_id),
4550
m_arguments(record.ExceptionInformation,
46-
record.ExceptionInformation + record.NumberParameters) {
47-
// Set up link to nested exception.
48-
if (record.ExceptionRecord) {
49-
m_next_exception.reset(new ExceptionRecord(
50-
*reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord),
51-
thread_id));
52-
}
53-
}
51+
record.ExceptionInformation + record.NumberParameters) {}
5452

5553
virtual ~ExceptionRecord() {}
5654

5755
DWORD
5856
GetExceptionCode() const { return m_code; }
5957
bool IsContinuable() const { return m_continuable; }
60-
const ExceptionRecord *GetNextException() const {
61-
return m_next_exception.get();
62-
}
6358
lldb::addr_t GetExceptionAddress() const { return m_exception_addr; }
6459

6560
lldb::tid_t GetThreadID() const { return m_thread_id; }
@@ -69,7 +64,6 @@ class ExceptionRecord {
6964
private:
7065
DWORD m_code;
7166
bool m_continuable;
72-
std::shared_ptr<ExceptionRecord> m_next_exception;
7367
lldb::addr_t m_exception_addr;
7468
lldb::tid_t m_thread_id;
7569
std::vector<ULONG_PTR> m_arguments;

0 commit comments

Comments
 (0)