Repository navigation
TextIOWrapper.reconfigure() crashes if encoding is not string or None #111942
Copy link
Copy link
Closed
Labels
topic-IOtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on Nov 10, 2023 Weird. The address sanitizer tests were passed in main and 3.12, but failed in 3.11. And I now can reproduce the failure locally in main.
The newly added tests exposed a bug in the
TextIOWrapperconstructor when pass a non-encodable "errors" argument.- added 3 commits that reference this issue
on Nov 15, 2023 Nice thanks, thanks.
There's an issue with the 3.11 backport, in
textiowrapper_change_encoding. Main had:+ Py_INCREF(errors); ... Py_SETREF(self->encoding, encoding); - Py_SETREF(self->errors, Py_NewRef(errors)); + Py_SETREF(self->errors, errors);
but in 3.11 this is:
+ Py_INCREF(errors); ... Py_INCREF(errors); Py_SETREF(self->encoding, encoding); Py_SETREF(self->errors, errors);i.e. there's an extra incref, but it looks -- at least to Git -- like the change that removes
Py_NewRefwas already applied.This was not caught because
test_iorefleaks tests were ineffective on 3.11.I'm preparing a fix.
- added a commit that references this issue
on Nov 8, 2024
Metadata
Metadata
Assignees
Labels
topic-IOtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Crash report
What happened?
Unlike to
TextIOWrapperconstructor,TextIOWrapper.reconfigure()does not check that the encoding argument is actually None or string. If it is not None, it calls_PyUnicode_EqualToASCIIStringthat only works with strings and crashes in debug build. There may be other similar errors in other arguments.CPython versions tested on:
3.10, 3.11, 3.12
Operating systems tested on:
No response
Output from running 'python -VV' on the command line:
No response
Linked PRs