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

ctype Structure keeps reference to function pointers #59445

Closed
vpelletier mannequin opened this issue Jul 2, 2012 · 2 comments
Closed

ctype Structure keeps reference to function pointers #59445

vpelletier mannequin opened this issue Jul 2, 2012 · 2 comments
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@vpelletier
Copy link
Mannequin

vpelletier mannequin commented Jul 2, 2012

BPO 15240
Nosy @jcea, @vpelletier
Files
  • reproduce.py: Test case (needs objgraph)
  • 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 2012-07-02.19:40:37.553>
    created_at = <Date 2012-07-02.19:29:42.167>
    labels = ['ctypes', 'type-bug', 'invalid']
    title = 'ctype Structure keeps reference to function pointers'
    updated_at = <Date 2012-07-02.19:51:59.156>
    user = 'https://github.com/vpelletier'

    bugs.python.org fields:

    activity = <Date 2012-07-02.19:51:59.156>
    actor = 'jcea'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-07-02.19:40:37.553>
    closer = 'vpelletier'
    components = ['ctypes']
    creation = <Date 2012-07-02.19:29:42.167>
    creator = 'vpelletier'
    dependencies = []
    files = ['26234']
    hgrepos = []
    issue_num = 15240
    keywords = []
    message_count = 2.0
    messages = ['164534', '164535']
    nosy_count = 2.0
    nosy_names = ['jcea', 'vpelletier']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15240'
    versions = ['Python 2.6', 'Python 2.7', 'Python 3.2']

    @vpelletier
    Copy link
    Mannequin Author

    vpelletier mannequin commented Jul 2, 2012

    When storing a ctype function pointer in a ctype structure field, a reference remains even when that field is overwritten with some values:

    • None
    • None cast into a function pointer
      But the reference is somehow removed when overwriting the field with a "real" function pointer (a lambda in attached test case).

    This causes problem when the structure is a class property and function pointer is created out of a method of the same class: a circular reference is created, which is not garbage-collected.

    To run the attached test case, you need objgraph[1], and to uncomment one (or none) of the commented-out lines in "close" method.

    [1] http://mg.pov.lt/objgraph/

    @vpelletier vpelletier mannequin added topic-ctypes type-bug An unexpected behavior, bug, or error labels Jul 2, 2012
    @vpelletier
    Copy link
    Mannequin Author

    vpelletier mannequin commented Jul 2, 2012

    Trying to generate a graph on several python and several uncommented lines, I see that my test case is incomplete. Time to review my copy.

    @vpelletier vpelletier mannequin closed this as completed Jul 2, 2012
    @vpelletier vpelletier mannequin added the invalid label Jul 2, 2012
    @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
    topic-ctypes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants