Xpra: Ticket #1725: Crash on macOS 10.13.2 (17C88)

Hi Antoine,

This one's a bit tricky to track down. I'd really appreciate it if you could bundle the .py files with the releases, then I feel I could be more helpful.

Seems I'm getting a crash somewhere in the darwin initialization, likely keyboard related?

Anyway, here's as much debugging as I managed:

import xpra.platform.darwin.osx_menu # precompiled from /Applications/Xpra.app/Contents/Resources/lib/python/xpra/platform/darwin/osx_menu.pyc
xpra.platform.keyboard
2017-12-17 20:28:13,658 KeyboardHelper((<bound method XpraClient.send of gtk2.client>, True, ['Control+Menu:toggle_keyboard_grab', 'Shift+Menu:toggle_pointer_grab', 'Shift+F11:toggle_fullscreen', '#+F1:show_menu', '#+F2:show_start_new_command', '#+F3:show_bug_report', '#+F4:quit', '#+F5:increase_quality', '#+F6:decrease_quality', '#+F7:increase_speed', '#+F8:decrease_speed', '#+F10:magic_key', '#+F11:show_session_info', '#+F12:toggle_debug', '#+plus:scaleup', '#+plusminus:scaleup', '#+minus:scaledown', '#+underscore:scaledown', '#+emdash:scaledown', '#+KP_Add:scaleup', '#+KP_Subtract:scaledown', '#+KP_Multiply:scalereset', '#+bar:scalereset', '#+question:scalingoff', '#+degree:scalereset'], False, None, None, None, None, None)) keyboard=<xpra.platform.darwin.keyboard.Keyboard object at 0x10ee8e250>
2017-12-17 20:28:13.658721+0000 Xpra[2632:22096] [general] Failed to set up CFPasteboardRef 'DefaultAsciiKeyboardLayoutPasteboard'. Error: <error: 0x7fffa1006d50> { count = 1, transaction: 0, voucher = 0x0, contents =
	"XPCErrorDescription" => <string: 0x7fffa1006ff8> { length = 18, contents = "Connection invalid" }
}
2017-12-17 20:28:13.658775+0000 Xpra[2632:22111] [general] Connection to 'pboard' server had an error: <error: 0x7fffa1006d50> { count = 1, transaction: 0, voucher = 0x0, contents =
	"XPCErrorDescription" => <string: 0x7fffa1006ff8> { length = 18, contents = "Connection invalid" }
}
2017-12-17 20:28:13.659535+0000 Xpra[2632:22096] [general] Failed to set up CFPasteboardRef 'DefaultAsciiKeyboardLayoutPasteboard'. Error: <error: 0x7fffa1006d50> { count = 1, transaction: 0, voucher = 0x0, contents =
	"XPCErrorDescription" => <string: 0x7fffa1006ff8> { length = 18, contents = "Connection invalid" }
}
2017-12-17 20:28:13.659599+0000 Xpra[2632:22096] [general] Failed to set up CFPasteboardRef 'AppleEnabledInputSourcesPasteboard'. Error: <error: 0x7fffa1006d50> { count = 1, transaction: 0, voucher = 0x0, contents =
	"XPCErrorDescription" => <string: 0x7fffa1006ff8> { length = 18, contents = "Connection invalid" }
}
2017-12-17 20:28:13.659716+0000 Xpra[2632:22096] GetInputSourceEnabledPrefs user file path = /var/root/Library/Preferences/com.apple.HIToolbox.plist
2017-12-17 20:28:13.659737+0000 Xpra[2632:22096] GetInputSourceEnabledPrefs effective user id path = 0
2017-12-17 20:28:13.659911+0000 Xpra[2632:22096] GetInputSourceEnabledPrefs user pref content = {
    AppleCurrentKeyboardLayoutInputSourceID = "com.apple.keylayout.US";
}
2017-12-17 20:28:13.660664+0000 Xpra[2632:22096] [general] Failed to set up CFPasteboardRef 'AppleEnabledInputSourcesPasteboard'. Error: <error: 0x7fffa1006d50> { count = 1, transaction: 0, voucher = 0x0, contents =
	"XPCErrorDescription" => <string: 0x7fffa1006ff8> { length = 18, contents = "Connection invalid" }
}
2017-12-17 20:28:13,662 get_layout_spec() current_keyboard=com.apple.keylayout.US, code=us
2017-12-17 20:28:13,662 get_layout_spec() other keyboards=(
    "com.apple.keylayout.US"
)
2017-12-17 20:28:13,663 get_layout_spec() layout=us, layouts=['us']
Process 2632 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x50)
    frame #0: 0x00007fff3df137d7 AppKit`-[NSTextInputContext dealloc] + 243
AppKit`-[NSTextInputContext dealloc]:
->  0x7fff3df137d7 <+243>: testb  $0x20, (%rax,%rcx)
    0x7fff3df137db <+247>: je     0x7fff3df13802            ; <+286>
    0x7fff3df137dd <+249>: movq   0x5c448bf4(%rip), %rdi    ; (void *)0x00007fff9a38db80: NSFunctionRowDevice
    0x7fff3df137e4 <+256>: movq   0x5c412305(%rip), %rsi    ; "removeObserver:forKeyPath:context:"
Target 0: (Xpra) stopped.


Sun, 17 Dec 2017 20:31:08 GMT - Ray Donnelly: component changed; keywords set


Sun, 17 Dec 2017 21:04:40 GMT - Ray Donnelly:

Oh, lldb bt gives:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x50)
  * frame #0: 0x00007fff3df137d7 AppKit`-[NSTextInputContext dealloc] + 243
    frame #1: 0x00000001091c62bb _objc.so`object_dealloc + 155
    frame #2: 0x000000010011405b libpython2.7.dylib`subtype_dealloc + 795
    frame #3: 0x00000001000d5ce4 libpython2.7.dylib`frame_dealloc + 116
    frame #4: 0x0000000100158abc libpython2.7.dylib`fast_function + 364
    frame #5: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #6: 0x0000000100158aa6 libpython2.7.dylib`fast_function + 342
    frame #7: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #8: 0x0000000100158aa6 libpython2.7.dylib`fast_function + 342
    frame #9: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #10: 0x0000000100158aa6 libpython2.7.dylib`fast_function + 342
    frame #11: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #12: 0x000000010014ce9a libpython2.7.dylib`PyEval_EvalCodeEx + 1690
    frame #13: 0x00000001000d799c libpython2.7.dylib`function_call + 364
    frame #14: 0x00000001000b17a3 libpython2.7.dylib`PyObject_Call + 99
    frame #15: 0x00000001000be8b6 libpython2.7.dylib`instancemethod_call + 182
    frame #16: 0x00000001000b17a3 libpython2.7.dylib`PyObject_Call + 99
    frame #17: 0x000000010010e54f libpython2.7.dylib`slot_tp_init + 175
    frame #18: 0x000000010010a73b libpython2.7.dylib`type_call + 347
    frame #19: 0x00000001000b17a3 libpython2.7.dylib`PyObject_Call + 99
    frame #20: 0x0000000100154ca4 libpython2.7.dylib`PyEval_EvalFrameEx + 31508
    frame #21: 0x000000010014ce9a libpython2.7.dylib`PyEval_EvalCodeEx + 1690
    frame #22: 0x00000001001589c6 libpython2.7.dylib`fast_function + 118
    frame #23: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #24: 0x000000010014ce9a libpython2.7.dylib`PyEval_EvalCodeEx + 1690
    frame #25: 0x00000001001589c6 libpython2.7.dylib`fast_function + 118
    frame #26: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #27: 0x0000000100158aa6 libpython2.7.dylib`fast_function + 342
    frame #28: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #29: 0x000000010014ce9a libpython2.7.dylib`PyEval_EvalCodeEx + 1690
    frame #30: 0x00000001001589c6 libpython2.7.dylib`fast_function + 118
    frame #31: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #32: 0x0000000100158aa6 libpython2.7.dylib`fast_function + 342
    frame #33: 0x00000001001542c4 libpython2.7.dylib`PyEval_EvalFrameEx + 28980
    frame #34: 0x000000010014ce9a libpython2.7.dylib`PyEval_EvalCodeEx + 1690
    frame #35: 0x000000010014c7f6 libpython2.7.dylib`PyEval_EvalCode + 54
    frame #36: 0x000000010017aa55 libpython2.7.dylib`PyRun_SimpleStringFlags + 149
    frame #37: 0x0000000100190008 libpython2.7.dylib`Py_Main + 2488
    frame #38: 0x00007fff67ee5115 libdyld.dylib`start + 1
    frame #39: 0x00007fff67ee5115 libdyld.dylib`start + 1

Sun, 17 Dec 2017 21:30:50 GMT - Ray Donnelly:

A quicker reproducer is, add this to to bottom of /Applications/Xpra.app/Contents/Resources/lib/python2.7/xpra/platform/darwin/keyboard.py

k = Keyboard()
k.get_layout_spec()

then run via:

/Applications/Xpra.app/Contents/MacOS/PythonExecWrapper python /Applications/Xpra.app/Contents/Resources/lib/python2.7/xpra/platform/darwin/keyboard.py

Mon, 18 Dec 2017 08:32:54 GMT - Antoine Martin: owner changed

I'd really appreciate it if you could bundle the .py files with the releases, then I feel I could be more helpful.

OK, bundling the source files will be the default in 2.3: r17692. (the space saving was tiny anyway)

Anyway, here's as much debugging as I managed:

How did you get that? gdb? I cannot reproduce any kind of crashes. I have tested this on 10.10, 10.11 and 10.12 only, as I do not have a 10.13 VM to test with. But based on the stacktrace, I came up with this change: r17693. There is a new osx beta build, does that fix things? (this code has not changed at all for a very long time, but maybe the behaviour of the pyobjc bindings has)


If that does not help, what command lines do you use to reproduce the crash? Have you tried turning off some options? (opengl, clipboard, tray, etc) Can you try older osx beta 2.2 builds to see when the crash first appears?

Do you also get the crash by running the tool:

/Applications/Xpra.app/Contents/Helpers/Keyboard_info

This ends up calling get_layout_spec too.


Tue, 19 Dec 2017 00:08:54 GMT - Ray Donnelly:

I'm blaming the update to macOS. I debugged this with lldb and python -v -v -v, changing the the end of /Applications/Xpra.app/Contents/MacOS/PythonExecWrapper

to:

exec lldb -- "$PYTHON" -v -v -v "$@"

Tue, 19 Dec 2017 00:16:32 GMT - Ray Donnelly:

Workaround I am using for now:

    def get_layout_spec(self):
        return 'us', ['us'], "", [], ""

Tue, 19 Dec 2017 00:17:29 GMT - Ray Donnelly:

I tested r17693 and it does indeed fix it. Thank you very much (again).


Mon, 22 Jan 2018 05:47:34 GMT - Antoine Martin: status changed; resolution, milestone set


Mon, 22 Jan 2018 12:38:02 GMT - Antoine Martin:

Still occurring apparently: #1750.


Sat, 23 Jan 2021 05:32:07 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1725