Skip to content

WxRenderWidget cannot be used on its own (segfault) #91

Open
@tlambert03

Description

@tlambert03

running the following example causes a segfault (rendercanvas v2.1.2, wxpython 4.2.3, macos, python 3.12)

import rendercanvas.wx
import wx

app = wx.App()
widget = rendercanvas.wx.WxRenderWidget()

while WxRenderCanvas() works just fine...

the fault seems to be happening in a size-related method:

➜ lldb python -- x.py
(lldb) target create "python"
Current executable set to '/Users/talley/dev/self/ndv/.venv/bin/python' (arm64).
(lldb) settings set -- target.run-args  "x.py"
(lldb) run
Process 8261 launched: '/Users/talley/dev/self/ndv/.venv/bin/python' (arm64)
Process 8261 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001032dd158 libwx_osx_cocoau_core-3.2.0.4.0.dylib`wxWindow::DoGetPosition(int*, int*) const + 52
libwx_osx_cocoau_core-3.2.0.4.0.dylib`wxWindow::DoGetPosition:
->  0x1032dd158 <+52>: ldr    x8, [x0]
    0x1032dd15c <+56>: ldr    x8, [x8, #0x98]
    0x1032dd160 <+60>: add    x1, sp, #0xc
    0x1032dd164 <+64>: add    x2, sp, #0x8
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001032dd158 libwx_osx_cocoau_core-3.2.0.4.0.dylib`wxWindow::DoGetPosition(int*, int*) const + 52
    frame #1: 0x0000000102ae55a8 _core.cpython-312-darwin.so`sipwxWindow::DoGetPosition(int*, int*) const + 156
    frame #2: 0x00000001032de498 libwx_osx_cocoau_core-3.2.0.4.0.dylib`wxWindow::DoSetSize(int, int, int, int, int) + 72
    frame #3: 0x0000000102ae5390 _core.cpython-312-darwin.so`sipwxWindow::DoSetSize(int, int, int, int, int) + 184
    frame #4: 0x0000000102af8828 _core.cpython-312-darwin.so`meth_wxWindow_SetSize(_object*, _object*, _object*) + 660
    frame #5: 0x0000000101631154 libpython3.12.dylib`cfunction_call + 72
    frame #6: 0x00000001014693b0 libpython3.12.dylib`_PyEval_EvalFrameDefault + 164064
    frame #7: 0x000000010165eb70 libpython3.12.dylib`method_vectorcall.llvm.13786586648554541543 + 172
    frame #8: 0x000000010146cd70 libpython3.12.dylib`_PyEval_EvalFrameDefault + 178848

and I tracked it down to this line in _rc_set_logical_size (which is triggered by _final_canvas_init)

self.SetSize(width, height)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions