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

Crash in garbage collection of the io.BytesIO buffer object #111211

Closed
serhiy-storchaka opened this issue Oct 23, 2023 · 2 comments
Closed

Crash in garbage collection of the io.BytesIO buffer object #111211

serhiy-storchaka opened this issue Oct 23, 2023 · 2 comments
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Oct 23, 2023

Crash report

What happened?

If the buffer created by io.BytesIO.getbuffer() is a part of a reference loop, the garbage collector can crash. Reproducer:

import gc, io
memio = io.BytesIO(b"1234567890")
buf = memio.getbuffer()
a = [buf]
a.append(a)
del memio, buf
del a
gc.collect()

It is because bytesiobuf_clear() clears self->source, but bytesiobuf_releasebuffer() uses it.

bytesiobuf_clear() was added in #101819.

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

No response

Output from running 'python -VV' on the command line:

No response

@serhiy-storchaka serhiy-storchaka added type-crash A hard crash of the interpreter, possibly with a core dump 3.12 bugs and security fixes 3.13 bugs and security fixes labels Oct 23, 2023
@chgnrdv
Copy link
Contributor

chgnrdv commented Oct 23, 2023

See also #111049

@serhiy-storchaka
Copy link
Member Author

Indeed, it is the same bug.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants