Cloudef / bemenu

Dynamic menu library and client program inspired by dmenu
GNU General Public License v3.0
1.16k stars 90 forks source link

[macOS] X11 bemenu crashes as soon as any key is pressed #349

Open fullmetalScience opened 1 year ago

fullmetalScience commented 1 year ago

Looking to get the x11 variant to work on macOS Ventura 13.4:

brew install make pkg-config xquartz cairo pango

git clone https://github.com/Cloudef/bemenu

cd bemenu &&
    CPPFLAGS='-I/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/Xlib.h -I/opt/X11/include/cairo/ -I/opt/homebrew/Cellar/pango/1.50.14/include/pango-1.0/' \
    sh build-osx.sh clients x11

I used this Xlib.h, because it was the only one that didn't cause errors when compiling. Maybe another one should be used?

bemenu opens as expected (!) then crashes once any key is pressed.

Debugging

% BEMENU_BACKEND=x11 LD_LIBRARY_PATH=. BEMENU_RENDERERS=. lldb --file ./bemenu-run
(lldb) target create "./bemenu-run"
Current executable set to '/Users/f/bemenu-master/bemenu-run' (arm64).
(lldb) r
Process 17746 launched: '/Users/f/bemenu-master/bemenu-run' (arm64)
jProcess 17746 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x000000010182f400 libX11.6.dylib`XmbLookupString
libX11.6.dylib`XmbLookupString:
->  0x10182f400 <+0>:  ldr    x8, [x0, #0x8]
    0x10182f404 <+4>:  cbz    x8, 0x10182f414           ; <+20>
    0x10182f408 <+8>:  ldr    x8, [x0]
    0x10182f40c <+12>: ldr    x6, [x8, #0x40]
Target 0: (bemenu-run) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
  * frame #0: 0x000000010182f400 libX11.6.dylib`XmbLookupString
    frame #1: 0x00000001000d90d4 bemenu-renderer-x11.so`bm_x11_window_key_press(window=0x0000600003508588, ev=0x000000016fdff130) at window.c:134:5 [opt]
    frame #2: 0x00000001000d7544 bemenu-renderer-x11.so`render(menu=<unavailable>) at x11.c:23:13 [opt]
    frame #3: 0x00000001000021bc bemenu-run`run_menu(client=0x0000000100008000, menu=0x0000000100304080, item_cb=(bemenu-run`item_cb at bemenu-run.c:157)) at common.c:615:14 [opt]
    frame #4: 0x00000001000025cc bemenu-run`main(argc=0, argv=0x000000016fdff6a0) at bemenu-run.c:187:39 [opt]
    frame #5: 0x00000001931f7f28 dyld`start + 2236
Cloudef commented 1 year ago

It seems to crash in the XmbLookupString call in window.c, wonder if the window->xic is null?

fullmetalScience commented 1 year ago

Can I check this from within the debugger?