diff options
| author | Pavel Labath <pavel@labath.sk> | 2025-06-02 09:39:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-02 09:39:56 +0200 |
| commit | e9fad0e91c49ca0f2669989dbad95664cbc9cbf3 (patch) | |
| tree | 334be0ec84d6ca6d6db42f670c01fa2622c4b884 /lldb/test/API/python_api | |
| parent | 246d5da7fedb39ba1ad838032f2946535606631d (diff) | |
| download | llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.zip llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.tar.gz llvm-e9fad0e91c49ca0f2669989dbad95664cbc9cbf3.tar.bz2 | |
[lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)
The problem was in calling GetLoadAddress on a value in the error state,
where `ValueObject::GetLoadAddress` could end up accessing the
uninitialized "address type" by-ref return value from `GetAddressOf`.
This probably happened because each function expected the other to
initialize it.
We can guarantee initialization by turning this into a proper return
value.
I've added a test, but it only (reliably) crashes if lldb is built with
ubsan.
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/value/TestValueAPI.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 9eaf2c9..0da5734 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -269,7 +269,14 @@ class ValueAPITestCase(TestBase): frame0.FindVariable("another_fixed_int_ptr").GetValue(), "0xaa", ) + a_null_int_ptr = frame0.FindVariable("a_null_int_ptr") + self.assertEqual(a_null_int_ptr.GetValue(), "0x0") + + # Check that dereferencing a null pointer produces reasonable results + # (does not crash). + self.assertEqual( + a_null_int_ptr.Dereference().GetError().GetCString(), "parent is NULL" + ) self.assertEqual( - frame0.FindVariable("a_null_int_ptr").GetValue(), - "0x0", + a_null_int_ptr.Dereference().GetLoadAddress(), lldb.LLDB_INVALID_ADDRESS ) |
