Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id C8179782BBC for ; Sat, 20 Jul 2019 15:40:55 +0000 (UTC) Received: by mail-io1-f52.google.com with SMTP id q22so64734135iog.4 for ; Sat, 20 Jul 2019 08:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3AbxvUDsyzViW8PLppSAkAAoRWPMW2OLcOZrhoBUeQ4=; b=VW4YwzGDp7v5eb3a5y6Dz0Zb4CTpllIWcjvujvJ2JPA8i8VBU/7mB/PHOLEaIOe7ZY qhoUn/4U+6ZoW670o/9Rdm6O7VNhPSkQxELdtH2Y9uFhNmYbtGm8GC3oKhnTENVQAdmn Er27CSY0qz4LLh7Lai7tH9r4871SIyiJkzhX/DFFY8kUzZzMi0O5EKLsGvoP9VD3h5qI pu6Y7OLPMpqrUkKbZs+Mh8FTLKLr2BCDWCswaZ44ZHX1aeGswzpWAWzCAlVNec/3T9Qu pRG1m9qamXEftyWkh9BCyHURnHdauvOa8sF34J8LdGUSI4zDia7AXmqUDwioufVsUblW RITw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3AbxvUDsyzViW8PLppSAkAAoRWPMW2OLcOZrhoBUeQ4=; b=b69VrOaZQ+Vxk03ef+hgN2d4cCJMJcsCnObNdSnw8Fx3pZghlkYCNJc59+1ePhWmYb B7cxkQQbAQTm2KXQ4MexmKte89s7T4EKTDATFzLFXC4o5egURf0Z7kZdoqj684dwjIKp sZmTx0H1dB3ScS6EcU6thCs+CQWYVlCXqUtUo9OFAKjebx9ZRpCHjhO/mZqwWx/TYzUA mAzx+8LWxDfEHTHTr2zRq3HLGnCY6hXlQcNlOsSDKHOVPh+lzl1TIFTbecoSpHKSBQP8 ikfd9eY3CrcpaHjZ1hc/Ats/Vq45k1UR9yEYb5YzngAwhquE8H54WJme/w2xzlKhmBne FywA== X-Gm-Message-State: APjAAAWWcZnafYuPU9z279fVre2da18QlQPoXtxAQC1SiKqXIGRBL50j 0pn7hKGzf5sEMUpim+jqOy4RltG5hvZxDg72WG8= X-Google-Smtp-Source: =?utf-8?q?APXvYqwk97rb94AVXPw3NAsrk9fzq+hplWQmQQ0e8e6A?= =?utf-8?q?cs0NNFNm+FLq+Bi9/YUu9Go1NxnZlQI5c55XyeKvHGOatAs=3D?= X-Received: by 2002:a6b:d008:: with SMTP id x8mr52498722ioa.129.1563637253867; Sat, 20 Jul 2019 08:40:53 -0700 (PDT) MIME-Version: 1.0 References: <20190719165408.6491577c@ncopa-desktop.copa.dup.pw> In-Reply-To: <20190719165408.6491577c@ncopa-desktop.copa.dup.pw> From: Vittorio Mori Date: Sat, 20 Jul 2019 17:40:45 +0200 Message-ID: Subject: Re: ZPAQ compiles but segfaults at pthread() with musl To: Natanael Copa Cc: alpine-user@lists.alpinelinux.org Content-Type: text/plain; charset="UTF-8" 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 That did the trick ! The problem was solved by adding the line: LDFLAGS=-Wl,-z,stack-size=1048576 To the Makefile. Thanks a million! Il giorno ven 19 lug 2019 alle ore 16:54 Natanael Copa ha scritto: > > 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. >