Skip to content

Instantly share code, notes, and snippets.

@goertzenator
Created November 3, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goertzenator/c0b19ee84d16f0e82681 to your computer and use it in GitHub Desktop.
Save goertzenator/c0b19ee84d16f0e82681 to your computer and use it in GitHub Desktop.
instruction to build Gentoo chroot and Elrang to demonstrate segfault
# do everything in throw-away dir
mkdir sftest
cd sftest
# get and expand gentoo chroot
wget http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/releases/x86/current-iso/stage3-i486-20141028.tar.bz2
wget http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/snapshots/portage-20141102.tar.bz2
mkdir chroot
sudo tar -jxf stage3-i486-20141028.tar.bz2 -C chroot
sudo tar -jxf portage-20141102.tar.bz2 -C chroot/usr
# enter chroot
sudo cp -L /etc/resolv.conf chroot/etc/
sudo mount -t proc proc chroot/proc
sudo mount --rbind /sys chroot/sys
sudo mount --rbind /dev chroot/dev
sudo linux32 chroot chroot /bin/bash
# first thing upon entering chroot
source /etc/profile
# install git (takes a couple of minutes)
emerge dev-vcs/git
# fetch and build erlang
git clone -b OTP-17.3.3 https://github.com/erlang/otp.git otp
cd otp && ./otp_build autoconf && ./configure --prefix=/usr/local/ --without-javac --disable-hipe --enable-dynamic-ssl-lib --enable-dirty-schedulers && make && make install
cd ..
# fetch and build the test app, run it
git clone https://github.com/goertzenator/dlibusb
cd dlibusb
make V=1
ERL_LIBS=.. erl
# in erlang shell, enter command that causes segfault...
dlibusb:mytest_io().
Result on my core-i7 laptop with Kubuntu 14.10:
goertzen-G550JK dlibusb # ERL_LIBS=.. erl
Erlang/OTP 17 [erts-6.2] [source] [smp:8:8] [ds:8:8:10] [async-threads:10] [kernel-poll:false]
Eshell V6.2 (abort with ^G)
1> dlibusb:mytest_io().
Segmentation fault (core dumped)
Result on my AMD Phenom 2 desktop with Windows 8.1 hosting Kubuntu 14.04 VM:
ubuntu64 dlibusb # ERL_LIBS=.. erl
Erlang/OTP 17 [erts-6.2] [source] [smp:3:3] [ds:3:3:10] [async-threads:10] [kernel-poll:false]
Eshell V6.2 (abort with ^G)
1> dlibusb:mytest_io().
Segmentation fault (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment