Ok, I was able to track down a __very__ minimal test case: the problem seems to be a "strange" interaction between the linker flag used during the creation of libutemper, and the inclusion of -lpthread[*] during the linking of mosh-server. It is not a problem related to mosh and/or libutempter. In fact I was able to create a test without involving these two.
$ cat boom.c extern void dofork(); int main() { dofork(); } $ cat dofork.c #include <unistd.h> void dofork() { fork(); } $ gcc -shared -Wl,-z,now -o libdofork.so dofork.o $ gcc -o boom boom.c -lpthread -L$(pwd) -ldofork $ LD_LIBRARY_PATH=$(pwd) ldd ./boom linux-vdso.so.1 (0x00007ffe817dc000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f16b38ed000) libdofork.so => /home/ghigo/mosh/libdofork.so (0x00007f16b36ec000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f16b3347000) /lib64/ld-linux-x86-64.so.2 (0x0000562eba12a000) $ LD_LIBRARY_PATH=$(pwd) ./boom Segmentation fault The key points are: - put a fork in a shared library - link the shared library with "-Wl,-z,now" - compile a program with libpthread and the library above (note: libpthread is not needed) - put libpthread before the library above Then I got a crash. The test was performed on a debian machine with libc6 2.22. Even on a fedora F23 (=libc-2.22) I got the crash. If I performed the same test on a debian machine with libc6 2.19 instead of libc6 2.22, the crash doesn't happen. If I remove "-lpthread" or "-Wl,-z,now" flag, the crash doesn't happen. If I put the fork() in the main(), the crash doesn't happen. My (limitated) knowledge doesn't suggest me any valid reason about why the crashes. However - if I remove "-Wl,-z,now" from libutempter mosh-server doesn't crash. - if I remove -lpthread from the linking of "mosh-server", mosh doesn't crash anymore. Pay attention that -lpthread is not needed, because the -pthread flag is sufficient. BR G.Baroncelli [*] BTW -lpthread was required by libprotobuf -- gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5