Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden --locals against trashed memory #194

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

godlygeek
Copy link
Contributor

@godlygeek godlygeek commented Jul 31, 2024

When attempting to produce a repr for local variables, attempt to cope
better with trashed memory:

  • Use "<invalid object at 0x1234>" as the repr of a PyObject* pointing
    directly at invalid memory, or one whose ob_type points at invalid
    memory.
  • Use "<list object at 0x1234>" as, for instance, the repr of a list containing an
    invalid ob_items pointer. More generally, use this for any object
    where we can determine the type, but generating the repr according to
    that type's rules fails due to accessing unmapped memory.

Test this with some ctypes abuse.

@godlygeek godlygeek self-assigned this Jul 31, 2024
@godlygeek godlygeek marked this pull request as draft July 31, 2024 23:30
@godlygeek godlygeek force-pushed the handle_trashed_locals branch from 0c7a734 to db11510 Compare August 1, 2024 00:00
@godlygeek godlygeek force-pushed the handle_trashed_locals branch from db11510 to 6721256 Compare August 1, 2024 00:06
When attempting to produce a repr for local variables, attempt to cope
better with trashed memory:

- Use "<invalid object at 0x1234>" as the repr of a `PyObject*` pointing
  directly at invalid memory, or one whose `ob_type` points at invalid
  memory.
- Use "<list object at 0x1234>" as, for instance, the repr of a list containing an
  invalid `ob_items` pointer. More generally, use this for any object
  where we can determine the type, but generating the repr according to
  that type's rules fails due to accessing unmapped memory.

Test this with some ctypes abuse.

Signed-off-by: Matt Wozniski <[email protected]>
@godlygeek godlygeek force-pushed the handle_trashed_locals branch from 6721256 to 456f12b Compare August 1, 2024 00:07
@godlygeek godlygeek marked this pull request as ready for review August 1, 2024 00:18
Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but left a comment regarding the (possible) flakiness of the test

@godlygeek godlygeek merged commit 07524ca into bloomberg:main Aug 1, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants