This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Interpreter segfault on attempted tab complete
Type: crash Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: FazJaxton, eryksun, ned.deily
Priority: normal Keywords:

Created on 2014-11-22 16:36 by FazJaxton, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg231520 - (view) Author: Kevin Smith (FazJaxton) Date: 2014-11-22 16:36
I am getting a segmentation fault in the interpreter when trying to tab complete options for a module.  I am running python 3.4.2 on Arch Linux.

Python 3.4.2 (default, Oct  8 2014, 13:44:52) 
[GCC 4.9.1 20140903 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sfml as sf
>>> t = sf.Texture.from_file ("sprites.png")
>>> s = sf.Sprite (t)
>>> s.Segmentation fault

When I type "s." then push tab to complete available options the interpreter segfaults.  This is with python-sfml-1.3-4 from the Arch repositories.  Tab completion for built-in types seems to work fine.
msg231530 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-11-22 20:52
This is very unlikely to be a problem in Python itself, rather a problem with the third-party python-sfml package or a build interaction issue.  Have you asked on either an Arch or a python-sfml list about this?  What happens if you you try "dir(s)" instead?
msg231532 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2014-11-22 21:42
This isn't a bug in Python or tab completion. You can reproduce the fault by referencing s.transformable twice and then deleting both references. 

The getter for TransformableDrawable.transformable calls wrap_transformable to create a wrapper for the underlying C++ object (self.p_transformable). 

TransformDrawable
https://github.com/Sonkun/python-sfml/blob/v1.3/src/sfml/graphics.pyx#L1175

wrap_transformable
https://github.com/Sonkun/python-sfml/blob/v1.3/src/sfml/graphics.pyx#L381

Thus each Transformable wrapper references the same C++ object. 

Transformable.__dealloc__ in graphics.pyx

https://github.com/Sonkun/python-sfml/blob/v1.3/src/sfml/graphics.pyx#L1117

gets Cythonized as __pyx_pf_4sfml_8graphics_13Transformable_2__dealloc__ in graphics.cpp. This executes the C++ delete that segfaults:

    delete __pyx_v_self->p_this;

For example:

    >>> x = s.transformable
    >>> y = s.transformable
    >>> del y

    Breakpoint 1, __pyx_pf_4sfml_8graphics_13Transformable_2__dealloc__
    (__pyx_v_self=0xb774d8c0) at src/sfml/graphics.cpp:21354
    21354	  delete __pyx_v_self->p_this;
    (gdb) p __pyx_v_self->p_this
    $1 = (sf::Transformable *) 0x8695b24
    (gdb) c
    Continuing.
    >>> del x

    Breakpoint 1, __pyx_pf_4sfml_8graphics_13Transformable_2__dealloc__
    (__pyx_v_self=0xb774d910) at src/sfml/graphics.cpp:21354
    21354	  delete __pyx_v_self->p_this;
    (gdb) p __pyx_v_self->p_this
    $2 = (sf::Transformable *) 0x8695b24
    (gdb) c
    Continuing.

    Program received signal SIGSEGV, Segmentation fault.
History
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67105
2014-11-22 22:28:33r.david.murraysetstatus: open -> closed
resolution: third party
stage: resolved
2014-11-22 21:42:32eryksunsetnosy: + eryksun
messages: + msg231532
2014-11-22 20:52:25ned.deilysetnosy: + ned.deily
messages: + msg231530
2014-11-22 16:36:18FazJaxtoncreate