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

Stack overflow in reprlib causes a core dump #69427

Closed
ceridwen mannequin opened this issue Sep 26, 2015 · 2 comments
Closed

Stack overflow in reprlib causes a core dump #69427

ceridwen mannequin opened this issue Sep 26, 2015 · 2 comments
Labels
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ceridwen
Copy link
Mannequin

ceridwen mannequin commented Sep 26, 2015

BPO 25240
Nosy @rhettinger, @tirkarthi, @iritkatriel

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 = None
closed_at = <Date 2021-09-07.16:30:05.794>
created_at = <Date 2015-09-26.16:47:58.489>
labels = ['library', 'type-crash']
title = 'Stack overflow in reprlib causes a core dump'
updated_at = <Date 2021-09-07.16:30:05.793>
user = 'https://bugs.python.org/ceridwen'

bugs.python.org fields:

activity = <Date 2021-09-07.16:30:05.793>
actor = 'iritkatriel'
assignee = 'none'
closed = True
closed_date = <Date 2021-09-07.16:30:05.794>
closer = 'iritkatriel'
components = ['Library (Lib)']
creation = <Date 2015-09-26.16:47:58.489>
creator = 'ceridwen'
dependencies = []
files = []
hgrepos = []
issue_num = 25240
keywords = []
message_count = 2.0
messages = ['251655', '401303']
nosy_count = 4.0
nosy_names = ['rhettinger', 'ceridwen', 'xtreak', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue25240'
versions = ['Python 3.4']

@ceridwen
Copy link
Mannequin Author

ceridwen mannequin commented Sep 26, 2015

I have a linked list implementation made of nested tuples with a custom repr:

    def __repr__(self):
        return 'LinkedList(' + ', '.join(repr(v) for v in self) + ')'

(Iterating over a LinkedList returns just its contents.)

When using Raymond Hettinger's recipe for finding the size in memory of an object, https://code.activestate.com/recipes/577504-compute-memory-footprint-of-an-object-and-its-cont/?in=user-178123 , when I set verbose=True and exceed the recursion limit with reprlib.repr, I get the following error:

Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007fa24200d700 (most recent call first):
File "<name of LinkedList file>.py", line 327 in __repr__
File "/usr/lib/python3.4/reprlib.py", line 135 in repr_instance
File "/usr/lib/python3.4/reprlib.py", line 64 in repr1
File "/usr/lib/python3.4/reprlib.py", line 54 in repr
File "recipe.py", line 46 in sizeof
[many instances of the above line repeated]
...
Aborted (core dumped)

The line in the recipe it fails when recursing on is:

        print(s, type(o), repr(o), file=stderr)

On 2.7 it fails with a RuntimeError as I'd expect.

@ceridwen ceridwen mannequin added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Sep 26, 2015
@iritkatriel
Copy link
Member

There was work on recursion in newer versions and several similar issues have been confirmed to be fixed. Since you didn't include a complete reproduction script, it's hard to know whether your case was fixed as well. I am therefore closing this, and request that you create a new issue with full reproduction information if you are still seeing this in a current version (>= 3.9).

@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
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant