Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on dynamically linked library when built with make WEBUI_USE_TLS=1 #454

Closed
garlic0x1 opened this issue Jul 11, 2024 · 6 comments
Closed

Comments

@garlic0x1
Copy link

Description

When the library is built with make WEBUI_USE_TLS=1, dynamically linking and calling functions segfaults. This is a problem since the version in the AUR is built this way, and on other distros as well afaik.

It works fine if I use the default make target.

Steps to reproduce

git clone https://github.com/webui-dev/webui
cd webui/
make WEBUI_USE_TLS=1
cd examples/C/minimal/
make
gdb ./main-dyn

Thread 1 "main-dyn" received signal SIGSEGV, Segmentation fault.
0x00007ffff7e9a040 in g_signal_connect_data () from ./webui-2.so
(gdb) bt
#0  0x00007ffff7e9a040 in g_signal_connect_data () from ./webui-2.so
#1  0x00007ffff700a579 in ?? () from /usr/lib/libgtk-3.so.0
#2  0x00007ffff6de2c57 in ?? () from /usr/lib/libgtk-3.so.0
#3  0x00007ffff6a390e7 in g_option_context_parse () from /usr/lib/libglib-2.0.so.0
#4  0x00007ffff6ddaab3 in gtk_parse_args () from /usr/lib/libgtk-3.so.0
#5  0x00007ffff6de2a33 in gtk_init_check () from /usr/lib/libgtk-3.so.0
#6  0x00007ffff6de417e in gtk_init () from /usr/lib/libgtk-3.so.0
#7  0x00007ffff7e75dc2 in _webui_wv_show () from ./webui-2.so
#8  0x00007ffff7e7144c in _webui_show_window () from ./webui-2.so
#9  0x00007ffff7e70f7a in _webui_show () from ./webui-2.so
#10 0x00007ffff7e68502 in webui_show () from ./webui-2.so
#11 0x0000555555555180 in ?? ()
#12 0x00007ffff7c97c88 in ?? () from /usr/lib/libc.so.6
#13 0x00007ffff7c97d4c in __libc_start_main () from /usr/lib/libc.so.6
#14 0x0000555555555085 in ?? ()

Environment info

Linux: 6.9.8
GCC: 14.1.1
WebUI: latest main branch

@hassandraga
Copy link
Member

image

@hassandraga
Copy link
Member

The g_signal_connect_data() causes gtk_init() to crash in Dynamic version of WebUI, while it works fine in the static version.

WebUI does not depend on installing GTK headers devl package to build, we just look for GTK libs and we load symbols directly... probably that what causes the crash for the dynamic version, and probably using the proper headers may solve the issue, but this will force any one want to build WebUI to install GTK headers first... However, because the mean goal of WebUI is to use a web browser as GUI and be portable as possible, I just then disabled the WebView in the dynamic version of WebUI in Linux for now. Hopefully someone can patch it with a better solution or a fix in the future.

Thank you @garlic0x1 for the report.

(9c07d87).

@garlic0x1
Copy link
Author

garlic0x1 commented Jul 12, 2024

Okay, I just pulled and the minimal example still doesn't work with WEBUI_USE_TLS=1, it seems like the same issue as this which was previously fixed #379, also I have GTK headers installed on my machine.

@hassandraga
Copy link
Member

Please make sure to re-build the lib and the example, normally if you run ./main-dyn it will ignore WebView and load the web browser instead.

@hassandraga
Copy link
Member

webui/src/webui.c

Line 10774 in 9c07d87

printf("[Core]\t\t_webui_wv_show() -> WebUI dynamic version does not support Linux WebView\n");

@garlic0x1
Copy link
Author

okay, the dynamic library works now, just not the examples when run as described in OP, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants