Skip to content

Commit dac7c75

Browse files
committed
demonstrate the bug?
1 parent d3b0fb0 commit dac7c75

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lib/test/test_external_inspection.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,5 +3660,36 @@ def test_get_stats_disabled_raises(self):
36603660
client_socket.sendall(b"done")
36613661

36623662

3663+
@requires_remote_subprocess_debugging()
3664+
@unittest.skipUnless(sys.platform == "linux", "requires /proc/self/mem")
3665+
@unittest.skipIf(
3666+
not PROCESS_VM_READV_SUPPORTED,
3667+
"Run on Linux with process_vm_readv support",
3668+
)
3669+
class TestInvalidDebugOffsets(RemoteInspectionTestBase):
3670+
@skip_if_not_supported
3671+
@unittest.skipUnless(
3672+
os.environ.get("PYTHON_REMOTE_DEBUG_UBSAN_PROBE") == "1",
3673+
"with UBSan probe",
3674+
)
3675+
def test_ubsan_probe_misaligned_interpreter_state_id_offset(self):
3676+
poison_code = textwrap.dedent(
3677+
"""\
3678+
interpreter_state_offset = 8 + 8 + 8 + 3 * 8
3679+
interpreter_id_offset = interpreter_state_offset + 8
3680+
fd = os.open(f"/proc/{pid}/mem", os.O_WRONLY)
3681+
os.lseek(fd, addr + interpreter_id_offset, 0)
3682+
os.write(fd, struct.pack("<Q", 1))
3683+
os.close(fd)
3684+
"""
3685+
)
3686+
3687+
with self._poisoned_debug_offsets_process(poison_code) as (_, info):
3688+
with self.assertRaisesRegex(RuntimeError, "Invalid debug offsets"):
3689+
unwinder = RemoteUnwinder(info["pid"], debug=True)
3690+
stack_trace = unwinder.get_stack_trace()
3691+
self.assertTrue(stack_trace)
3692+
3693+
36633694
if __name__ == "__main__":
36643695
unittest.main()

0 commit comments

Comments
 (0)