dat-ecosystem / dat

:floppy_disk: peer-to-peer sharing & live syncronization of files via command line
https://dat.foundation
BSD 3-Clause "New" or "Revised" License
8.24k stars 449 forks source link

segfault on Alpine Linux #931

Closed deed02392 closed 4 years ago

deed02392 commented 6 years ago
docker pull alpine
docker run -it alpine /bin/sh
apk update
apk add nodejs
npm install -g dat
mkdir test
cd test
echo "hi" > test.txt
dat share .
Segmentation fault (core dumped)

SEGFAULT!

Possible cause: Alpine linux has a smaller than usual stack size. You may find that the default stack size on Alpine processes is too small for dat and causes the crash.

This needs to be addressed by the dat process requesting a certain stack size. You could use the default in common distros such as Debian, or investigate how large a one you actually need.

arvati commented 5 years ago

I´m having this same trouble running dat on alpine lxc container. Command dat share works fine until i try to clone at some other machine (running other linux distros):

DEBUG=dat,dat-node dat share .
  dat Dat DEBUG mode engaged, enabling quiet mode +0ms
  dat dat 13.12.2 +63ms
  dat node v10.15.3 +2ms
  dat Sharing archive { _: [ '.' ],
  utp: true,
  debug: false,
  quiet: true,
  sparse: false,
  import: true,
  ignoreHidden: true,
  'ignore-hidden': true,
  watch: true,
  logspeed: 400,
  dir: '.' } +0ms
  dat-node archive ready. version: 4 +0ms
  dat-node importFiles() { watch: true,
  dereference: true,
  count: true,
  indexing: true,
  _: [ '.' ],
  utp: true,
  debug: false,
  quiet: true,
  sparse: false,
  import: true,
  ignoreHidden: true,
  'ignore-hidden': true,
  logspeed: 400,
  dir: '.',
  ignore: [Function: ignore] } +0ms
  dat-node IMPORT ignore: / +176ms
  dat-node IMPORT ignore: /.dat +5ms
  dat-node IMPORT ignore: /.dat/content.bitfield +78ms
  dat-node IMPORT ignore: /.dat/content.key +11ms
  dat-node IMPORT ignore: /.dat/content.signatures +3ms
  dat-node IMPORT ignore: /.dat/content.tree +3ms
  dat-node IMPORT ignore: /.dat/metadata.bitfield +3ms
  dat-node IMPORT ignore: /.dat/metadata.data +5ms
  dat-node IMPORT ignore: /.dat/metadata.key +3ms
  dat-node IMPORT ignore: /.dat/metadata.ogd +3ms
  dat-node IMPORT ignore: /.dat/metadata.signatures +2ms
  dat-node IMPORT ignore: /.dat/metadata.tree +3ms
  dat-node IMPORT skip: /dat.json +20ms
  dat-node IMPORT skip: /test.txt +5ms

No error until try to clone somewhere else: Segmentation fault

arvati commented 5 years ago

It works on Alpne installing dat this way:

apk update
apk add nodejs nodejs-npm
apk add python make g++ libtool autoconf automake gettext
apk add m4 libsodium libsodium-dev

apk del iptables

npm install -g dat --unsafe-perm --build-from-source

Package sodium-native will be compiled during dat install and will take a lot of time to finish. There is a problem with utp-native that normally prebuilt binary is libc based, and thus doesn't work on Alpine Linux which uses MUSL, thats why you have to give option --build-from-source.

RangerMauve commented 5 years ago

Jeeze, that's a hard one to address. @mafintosh Any suggestions as to what we could do about the native stuff?

thadguidry commented 5 years ago

Instead of Alpine... If you pull some official images of well-known distribution you get the following sizes: centos:7 = 191 MB debian:jessie = 194 MB debian:jessie-slim = 80 MB ubuntu:16.04 = 129 MB alpine:3.4 = 4.8 MB

Or just use Minideb https://dzone.com/articles/minideb-a-minimalist-debian-based-docker-image

mafintosh commented 5 years ago

We added musl support in prebuildify recently so if someone wants to figure prebuilding the native deps on travis for musl I’m open to it.

arvati commented 5 years ago

I would love to but i know nothing about prebuildify. I could help testing anyway. did you take a look at https://github.com/codercom/nbin/issues/3 ? this npm pack lokk like replacement of travis.

okdistribute commented 4 years ago

This should no longer be an issue on dat 14.0.2, can you test?