Skip to content

gh-157364: Fix use-after-free in TextIOWrapper during reentrant detach - #157370

Open
ashm-dev wants to merge 3 commits into
python:mainfrom
ashm-dev:gh-157364
Open

gh-157364: Fix use-after-free in TextIOWrapper during reentrant detach#157370
ashm-dev wants to merge 3 commits into
python:mainfrom
ashm-dev:gh-157364

Conversation

@ashm-dev

@ashm-dev ashm-dev commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Comment thread Modules/_io/textio.c Outdated
Comment thread Modules/_io/textio.c Outdated

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I just have a last request on the test.

@cmaloney: Would you mind to double check this change? You wrote the first iteration if I recall correctly.

wrapper = self.TextIOWrapper(
self.BufferedReader(raw), encoding="utf-8")
method = getattr(wrapper, method_name)
self.assertEqual(method(), "ab\n")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you check that wrapper is actually detached? Maybe get wrapper.buffer and expect PyExc_ValueError("underlying buffer has been detached")?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants