Skip to content

Cython version leaks all handles #8

@jrtc27

Description

@jrtc27

In the Cython version, the handles are closed in __del__ both for DTraceConsumer and DTraceContinuousConsumer (used by DTraceConsumerThread). However, these are extension types, and Cython does not use __del__ for extension types (for whatever reason), so they will never be called (the explicit del self.consumer in DTraceConsumerThread's destructor, which is called as it's a normal Python object, just ensures the DTraceContinuousConsumer gets deallocated, but the consumer's __del__ still won't be called). I believe using __dealloc__ for the two extension classes would work (though handle must be checked for being non-null first).

This has also exposed a (minor) potential issue: with Cython, __init__ can end up being called multiple times, so technically handle could be initialised twice, leaking the old return from dtrace_open. To be truly correct, either __init__ should guard against this, or __cinit__ should be used instead, which will only ever be called once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions