[ocaml-ctypes] Spinning process on osx

Daniel Bünzli daniel.buenzli at erratique.ch
Sat Dec 28 01:39:44 GMT 2013


Ok this thing is too annoying, either my code runs an infinite loop (4.01) or I have to wait over 6 minutes for my code to compile (4.00.1). 

So I gave it a go, making a full script this time that works in an ocaml repo checkout, see the end of this message. Note that in practice doing a bisect is not as easy as 

   git bisect start 4.00.1 4.01.0
   git bisect run script

since you tend to fall on commits in which ocaml doesn't build which screws the search procedure. So in practice you have to watch carefully which checkouts fail because ocaml fails to build and which because of your actual don't so you can restart at slightly different points (e.g. parent or successor of a bad, good commit) to avoid falling on the checkouts that fail for other reasons than your bug. So I guess I really understand now the benefits of CI. 

In any case the offending commit is: 

    https://github.com/ocaml/ocaml/commit/b2636c22d55b15f55a02b3

Before I submit something upstream does that ring a bell to anyone ? Do you think it's maybe a specific libffi issue/interaction ? 

Daniel


The bug happens with:

> gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix



> uname -a
Darwin hehey.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64



To reproduce let $T be a directory (change the $T variable accordingly in the script).

brew update && brew install sdl2
cd $T 
git clone https://github.com/ocaml/ocaml
cd ocaml
git checkout trunk
$T/sdlspin.sh # exits with 0 if there is no bug

---- sdlspin.sh ----
#!/bin/sh

T=/Users/dbuenzli/tmp
cd $T/ocaml

# OCaml
./configure --prefix $T/ocaml
make world.opt 
make install

export PATH="$T/ocaml/bin:$PATH"

# Findlib 
curl -O http://download.camlcity.org/download/findlib-1.4.tar.gz
tar -xvzf findlib-1.4.tar.gz
cd findlib-1.4
./configure \
 -bindir $T/ocaml/bin \
 -mandir $T/ocaml/man \
 -sitelib $T/ocaml/lib/ocaml/site-lib \
 -config $T/ocaml/findlib.conf
make all opt install
cd ..
curl -O -L \
 https://github.com/ocamllabs/ocaml-ctypes/archive/ocaml-ctypes-0.2.2.tar.gz

# Ctypes 
tar -xvzf ocaml-ctypes-0.2.2.tar.gz 
cd ocaml-ctypes-ocaml-ctypes-0.2.2 # WTF
make
make install 
cd ..

# Tsdl overwrite test.ml with bug so we can directly compile
git clone https://github.com/dbuenzli/tsdl.git
curl http://erratique.ch/tmp/tsdl_bug.ml > tsdl/test/test.ml
cd tsdl 
./build test.native

(./test.native) & pid=$!
sleep 2
kill -9 $pid 2>/dev/null
if [ "$?" = "0" ]; then  
  echo "Spinning, bug" 
  # Killed we were spinning.
  EXIT=1
else
  # Not killed we finished, no bug
  echo "No spinning, no bug"
  EXIT=0
fi
cd ..

# Cleanup 
git clean -q -f -d -x 
rm -rf tsdl

exit $EXIT
-------------------------




More information about the Ctypes mailing list