Xpra-org / gtk-osx-build

Build setup to help building the Mac OS X port of GTK+
http://gtk-osx.sourceforge.net/
0 stars 2 forks source link

objc crash is back #1

Closed totaam closed 3 years ago

totaam commented 3 years ago

I believe this is identical to https://github.com/Xpra-org/xpra/issues/2822.

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0xffffffffae789a30
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [28366]

VM Regions Near 0xffffffffae789a30:
--> shared memory          00007fffffe36000-00007fffffe37000 [    4K] r-x/r-x SM=SHM  

Application Specific Information:
objc_msgSend() selector name: self

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x00007fff5b3d7397 objc_msgSend + 23
1   _objc.so                        0x000000010edaafb6 pythonify_c_value + 374 (objc_support.m:1891)
2   _objc.so                        0x000000010eda6e5e object_new + 350
3   libpython3.9.dylib              0x000000010a18bfcc type_call + 76
4   libpython3.9.dylib              0x000000010a131777 _PyObject_MakeTpCall + 375 (call.c:191)
5   libpython3.9.dylib              0x000000010a2212e8 call_function + 776
6   libpython3.9.dylib              0x000000010a21dbea _PyEval_EvalFrameDefault + 27114 (ceval.c:3535)
7   libpython3.9.dylib              0x000000010a132005 function_code_fastcall + 229 (pycore_ceval.h:40)
8   libpython3.9.dylib              0x000000010a22117b call_function + 411
9   libpython3.9.dylib              0x000000010a21da76 _PyEval_EvalFrameDefault + 26742 (ceval.c:3505)
10  libpython3.9.dylib              0x000000010a22227d _PyEval_EvalCode + 3245 (pycore_ceval.h:40)
11  libpython3.9.dylib              0x000000010a131f11 _PyFunction_Vectorcall + 257 (call.c:404)
12  libpython3.9.dylib              0x000000010a22117b call_function + 411
13  libpython3.9.dylib              0x000000010a21da76 _PyEval_EvalFrameDefault + 26742 (ceval.c:3505)
14  libpython3.9.dylib              0x000000010a22227d _PyEval_EvalCode + 3245 (pycore_ceval.h:40)
15  libpython3.9.dylib              0x000000010a131f11 _PyFunction_Vectorcall + 257 (call.c:404)
16  libpython3.9.dylib              0x000000010a22117b call_function + 411
17  libpython3.9.dylib              0x000000010a21daa0 _PyEval_EvalFrameDefault + 26784 (ceval.c:3488)
18  libpython3.9.dylib              0x000000010a22227d _PyEval_EvalCode + 3245 (pycore_ceval.h:40)
19  libpython3.9.dylib              0x000000010a131f11 _PyFunction_Vectorcall + 257 (call.c:404)
20  libpython3.9.dylib              0x000000010a22117b call_function + 411
21  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
22  libpython3.9.dylib              0x000000010a22227d _PyEval_EvalCode + 3245 (pycore_ceval.h:40)
23  libpython3.9.dylib              0x000000010a131f11 _PyFunction_Vectorcall + 257 (call.c:404)
24  libpython3.9.dylib              0x000000010a22117b call_function + 411
25  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
26  libpython3.9.dylib              0x000000010a132005 function_code_fastcall + 229 (pycore_ceval.h:40)
27  libpython3.9.dylib              0x000000010a22117b call_function + 411
28  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
29  libpython3.9.dylib              0x000000010a132005 function_code_fastcall + 229 (pycore_ceval.h:40)
30  libpython3.9.dylib              0x000000010a22117b call_function + 411
31  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
32  libpython3.9.dylib              0x000000010a132005 function_code_fastcall + 229 (pycore_ceval.h:40)
33  libpython3.9.dylib              0x000000010a22117b call_function + 411
34  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
35  libpython3.9.dylib              0x000000010a132005 function_code_fastcall + 229 (pycore_ceval.h:40)
36  libpython3.9.dylib              0x000000010a22117b call_function + 411
37  libpython3.9.dylib              0x000000010a21db42 _PyEval_EvalFrameDefault + 26946 (ceval.c:3519)
38  libpython3.9.dylib              0x000000010a22227d _PyEval_EvalCode + 3245 (pycore_ceval.h:40)
39  libpython3.9.dylib              0x000000010a217130 PyEval_EvalCode + 64 (ceval.c:4359)
40  libpython3.9.dylib              0x000000010a268b8f PyRun_StringFlags + 319 (pythonrun.c:1219)
41  libpython3.9.dylib              0x000000010a268a05 PyRun_SimpleStringFlags + 69 (pythonrun.c:497)
42  libpython3.9.dylib              0x000000010a287739 Py_RunMain + 521 (main.c:246)
43  libpython3.9.dylib              0x000000010a2883bb pymain_main + 411 (main.c:708)
44  libpython3.9.dylib              0x000000010a28841b Py_BytesMain + 43 (main.c:731)
45  libdyld.dylib                   0x00007fff5cbac3d5 start + 1

We either need to update the patch or find another way to safely access the underlying window. Perhaps using https://gitlab.gnome.org/jralls/gtk/-/commit/242b76a7711ab6326a220f9e65e6fc282dc2f8b1 : How about moving the two function decls to a new, public header that has to be specifically included if one wants access to the AppKit shim functions

totaam commented 3 years ago

So... the change was not included in 3.24.29 released in April, but it should be in 3.24.30 released just 2 days ago.

First thing: merged the 3.24.29 update from upstream: eb54185d85043263d8defebcd048be4ea2b77981

Then updated to 3.24.30 810de8e08bcb4c1351185f4597d6f36c4b2bcbb8, which failed to build in many places because it looked for the symbols in the dylib already installed instead of the one it just built! ie:

dyld: Symbol not found: _gtk_file_chooser_widget_accessible_get_type
  Referenced from: /Volumes/OSX-10.14.x-Dev/cache-jhbuild/build/gtk+-3.24.30/tmp-introspecth6jnu6ek/Gtk-3.0
  Expected in: /Users/macos/gtk/inst/lib/libgtk-3.0.dylib
 in /Volumes/OSX-10.14.x-Dev/cache-jhbuild/build/gtk+-3.24.30/tmp-introspecth6jnu6ek/Gtk-3.0
Command '['/Volumes/OSX-10.14.x-Dev/cache-jhbuild/build/gtk+-3.24.30/tmp-introspecth6jnu6ek/Gtk-3.0', '--introspect-dump=/Volumes/OSX-10.14.x-Dev/cache-jhbuild/build/gtk+-3.24.30/tmp-introspecth6jnu6ek/functions.txt,/Volumes/OSX-10.14.x-Dev/cache-jhbuild/build/gtk+-3.24.30/tmp-introspecth6jnu6ek/dump.xml']' died with <Signals.SIGABRT: 6>.
[736/1288] Compiling C object demos/gtk-demo/gtk3-demo.p/paint.c.o

Solved by skipping any file that failed to build and then copying the resulting libgtk-3.0.dylib over. Next build goes through fine.

Next hurdle: the new compatibility header file refers to a header file which does not exist!

In file included from xpra/platform/darwin/gdk3_bindings.c:758:
/Users/macos/gtk/inst/include/gtk-3.0/gdk/quartz/gdkquartz-cocoa-access.h:28:10: fatal error: 'gdk/quartz/gdkquartz.h' file not found
#include <gdk/quartz/gdkquartz.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Simply commenting out this include finally allows us to build xpra with an almost pristine newer GTK version and avoid the crash!

totaam commented 3 years ago

The better fix is to use the correct path in that header file:

#include <gdk/gdkquartz.h>
totaam commented 1 year ago

The correct fix for gdk/gdkquartz.h is in https://github.com/Xpra-org/gtk-osx-build/blob/master/patches/gtk-3-24-36-quartz-cocoa-access-path.patch Submitted upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5648