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

bug: reuse of exception causing memory leak #70

Open
j123b567 opened this issue Jun 16, 2020 · 0 comments
Open

bug: reuse of exception causing memory leak #70

j123b567 opened this issue Jun 16, 2020 · 0 comments

Comments

@j123b567
Copy link

j123b567 commented Jun 16, 2020

In the code, there is

key_string_error = TypeError('Key/name must be a string!')

which create exception on place, where it does not occur.

And later use

raise self.key_string_error

Which append new tracebak to existing one in this exception object so the traceback grows without bounds.

It is later imposible to debug the code, because the traceback can be very long. It also introduces memory leak, because key_string_error is class variable and is never freed.

Expected solution:

Raise new instance of TypeError('Key/name must be a string!') every time, or create new exception type with predefined message for this.

Example code to reproduce the issue:

import pickledb
import traceback

db = pickledb.load('example.db', False)
for i in range(100):
    try:
        db.set({}, "")
    except TypeError:
        print("***********************************")
        traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant