Received: from mx1.tetrasec.net (mx1.tetrasec.net [74.117.190.25]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 6182A782BE2 for ; Fri, 19 Jul 2019 14:54:19 +0000 (UTC) Received: from mx1.tetrasec.net (mail.local [127.0.0.1]) by mx1.tetrasec.net (Postfix) with ESMTP id 05EE79E341C; Fri, 19 Jul 2019 14:54:17 +0000 (UTC) Received: from ncopa-desktop.copa.dup.pw (67.63.200.37.customer.cdi.no [37.200.63.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: alpine@tanael.org) by mx1.tetrasec.net (Postfix) with ESMTPSA id 10AF29E0365; Fri, 19 Jul 2019 14:54:15 +0000 (UTC) Date: Fri, 19 Jul 2019 16:54:08 +0200 From: Natanael Copa To: Vittorio Mori Cc: alpine-user@lists.alpinelinux.org Subject: Re: ZPAQ compiles but segfaults at pthread() with musl Message-ID: <20190719165408.6491577c@ncopa-desktop.copa.dup.pw> In-Reply-To: References: X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-alpine-linux-musl) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 19 Jul 2019 09:40:13 +0200 Vittorio Mori wrote: > Hello everyone. Hi! > I have an issue compiling the ZPAQ compressor/archive utility from Matt Mahoney. Do we have this package in our repository or is it something you built yourself? > It seems there are problems with pthread() function: the program > compiles correctly, but segfaults at some point. > > This is what I get from GDB: > > Starting program: /root/zpaq a test / > zpaq v7.15 journaling archiver, compiled May 3 2019 > test.zpaq: 0 versions, 0 files, 0 fragments, 0.000000 MB > Updating test.zpaq at offset 0 + 0 > Adding 1326.112348 MB in 42966 files -method 14 -threads 1 at > 2019-05-03 12:12:34. > [New LWP 2317] > [New LWP 2318] > 1.27% 0:00:27 [1..236] 16754818 -method 14,97,0 > > Thread 2 "zpaq" received signal SIGSEGV, Segmentation fault. > [Switching to LWP 2317] > 0x00007ffff7fac5c0 in libzpaq::Predictor::Predictor(libzpaq::ZPAQL&) () > (gdb) I think this should be reported upstream. > (gdb) backtrace > #0 0x00007ffff7fac5c0 in libzpaq::Predictor::Predictor(libzpaq::ZPAQL&) () > #1 0x00007ffff7fc7122 in > libzpaq::compressBlock(libzpaq::StringBuffer*, libzpaq::Writer*, char > const*, char const*, char const*, bool) () > #2 0x00007ffff7f83284 in compressThread(void*) () > #3 0x00007ffff7fdd2c6 in start (p=) at > src/thread/pthread_create.c:147 > #4 0x00007ffff7fddd11 in __clone () at src/thread/x86_64/clone.s:21 > Backtrace stopped: frame did not save the PC > (gdb) > > (gdb) frame 3 > #3 0x00007ffff7fdd2c6 in start (p=) at > src/thread/pthread_create.c:147 > 147 src/thread/pthread_create.c: No such file or directory. > > > I wonder if there is a trivial solution to this problem. The usual suspect is that ZPAQ is allocating big buffer on stack. The default thread stack size is significantly smaller with musl than glibc. You can try increase the default thread stack size. there are a couple of ways to do so: - use phtread_attr_setstacksize to set the stacksize when calling pthread_create - there is a way to initialize the pthread stack size. can be done from main(), or from a ctor (but does not work if library is dlopened iirc). I don't remember the details how that is done. - Pass linker flag: -Wl,-z,stack-size=1048576 > I've found a (kinda ugly, but useful) workaround for this installing > the glibc binaries from sgerrand repository on github > and using a binary compiled from another distro (with glibc).. > > Any help appreciated.