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

_Py_ForgetReference crash when called from _PyUnicode_New on MemoryError #46881

Closed
gpshead opened this issue Apr 14, 2008 · 3 comments
Closed
Assignees
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@gpshead
Copy link
Member

gpshead commented Apr 14, 2008

BPO 2629
Nosy @gpshead, @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/gpshead'
closed_at = <Date 2008-08-19.20:12:11.811>
created_at = <Date 2008-04-14.02:56:08.725>
labels = ['type-crash']
title = '_Py_ForgetReference crash when called from _PyUnicode_New on MemoryError'
updated_at = <Date 2008-08-19.20:12:11.810>
user = 'https://github.com/gpshead'

bugs.python.org fields:

activity = <Date 2008-08-19.20:12:11.810>
actor = 'gregory.p.smith'
assignee = 'gregory.p.smith'
closed = True
closed_date = <Date 2008-08-19.20:12:11.811>
closer = 'gregory.p.smith'
components = []
creation = <Date 2008-04-14.02:56:08.725>
creator = 'gregory.p.smith'
dependencies = []
files = []
hgrepos = []
issue_num = 2629
keywords = []
message_count = 3.0
messages = ['65456', '71442', '71475']
nosy_count = 2.0
nosy_names = ['gregory.p.smith', 'pitrou']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue2629'
versions = ['Python 2.6']

@gpshead
Copy link
Member Author

gpshead commented Apr 14, 2008

In _PyUnicode_New() a unicode object is taken from the freelist but if
the unicode_resize() call fails and returns -1, the goto onerror calls
_Py_ForgetReference on the unicode object... But it has NULL _ob_prev
and _ob_next values causing a crash when they're used.

How to reproduce:

  • Make a 32-bit --with-pydebug build of Python trunk.
  • Run it on a machine with lots of ram (at least 3gigs recommended, or
    lots of swap and a heap of patience):
./python
Python 2.6a2+ (trunk:62336M, Apr 13 2008, 18:51:30)
>>> msg = 'A'*2000111222
>>> x = msg.decode('utf8')

It segmentation faults in _Py_ForgetReference.

@gpshead gpshead added the type-crash A hard crash of the interpreter, possibly with a core dump label Apr 14, 2008
@pitrou
Copy link
Member

pitrou commented Aug 19, 2008

This should has been fixed by Amaury as part of another patch (the one
which is tested for in test_raiseMemError).
Could you try again?

@gpshead
Copy link
Member Author

gpshead commented Aug 19, 2008

Verified fixed.

Python 2.6b2+ (trunk:65871, Aug 19 2008, 13:10:07)
>>> msg = 'A'*2000111222
[12389 refs]
>>> x = msg.decode('utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/google/home/gps/python/trunk/Lib/encodings/utf_8.py",
line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
MemoryError
[12431 refs]

@gpshead gpshead closed this as completed Aug 19, 2008
@gpshead gpshead self-assigned this Aug 19, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants