d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
524 stars 40 forks source link

Unexpected termination 11 on Alpine #204

Closed hugoromo closed 3 months ago

hugoromo commented 3 months ago

Error when trying to setup whatsapp:

Unexpected termination 11 Callstack: Segmentation fault

Environment:

d99kris commented 3 months ago

Hi @hugoromo - thanks for reporting an issue. Could you please try run the setup with extra verbose logging: nchat -ee -s and share the log content of ~/.nchat/log.txt?

hugoromo commented 3 months ago

Hi! Here are the logs after running with those arguments:

2024-03-16 21:20:11.910 | INFO  | starting nchat v4.40  (main.cpp:239)
2024-03-16 21:20:14.929 | ERROR | failed dlopen /usr/local/bin/../lib/libwmchat.so  (main.cpp:74)
2024-03-16 21:20:14.929 | ERROR | dlerror Error relocating /usr/local/bin/../lib/libwmchat.so: sqlite3_set_clientdata: initial-exec TLS resolves to dynamic definition in /usr/local/bin/../lib/libwmchat.so  (main.cpp:78)
Unexpected termination 11
Callstack:
d99kris commented 3 months ago

Thanks! It appears initial-exec TLS resolves to dynamic definition can be worked around by disabling HAS_DYNAMICLOAD (which avoids using dlopen):

mkdir -p build && cd build
cmake -DHAS_DYNAMICLOAD=OFF .. && make -s

However, we then encounter another crash during startup:

Thread 2 "nchat" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 9226]
0x0000fffff67db708 in runtime.argv_index (argv=0x80000001, i=-159307743) at /usr/lib/go/src/runtime/runtime1.go:63
63              return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize))
(gdb) bt
#0  0x0000fffff67db708 in runtime.argv_index (argv=0x80000001, i=-159307743) at /usr/lib/go/src/runtime/runtime1.go:63
#1  runtime.sysargs (argc=-159307744, argv=0x80000001) at /usr/lib/go/src/runtime/os_linux.go:236
#2  0x0000fffff67eff5c in runtime.args (c=-159307744, v=0x80000001) at /usr/lib/go/src/runtime/runtime1.go:69
#3  0x0000fffff6813b68 in runtime.args (c=-159307744, v=0x80000001) at <autogenerated>:1
#4  0x0000fffff680f4dc in runtime.rt0_go () at /usr/lib/go/src/runtime/asm_arm64.s:84

This is due to an incompatibility between Go and musl w.r.t. c-shared library usage (which nchat uses to link Go library whatsmeow for WhatsApp support).

The linked issue has been open since 2015, so it appears that neither the Go nor the Musl projects are very interested in fixing it. Based on this I'll probably need to consider musl support out-of-scope for nchat's whatsapp feature.

I'll leave this issue open for a while and see if I can add some musl detection to provide a more user-friendly error message.

hugoromo commented 3 months ago

Too bad if that means dropping support for WhatsApp. I might just stop using that service anyway.. Cheers!

d99kris commented 3 months ago

In above commit I've added a warning when trying to set up whatsapp on non-glibc systems.