Compiling xfractint

Context

tth@gally:~/WWW/buvette$ uname -a
Linux gally 2.6.12-10-686 #1 Wed Feb 7 03:56:37 UTC 2007 i686 GNU/Linux
tth@gally:~/WWW/buvette$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
      --enable-languages=c,c++,java,f95,objc,ada,treelang
      --prefix=/usr --with-gxx-include-dir=/usr/include/c++/4.0.2
      --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls
      --without-included-gettext --enable-threads=posix --program-suffix=-4.0
      --enable-__cxa_atexit --enable-libstdcxx-allocator=mt
      --enable-clocale=gnu --enable-libstdcxx-debug
      --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo
      --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
      --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)

Not compiling helpfile ?

After unpacking this tarball, and changing nothing to the supplied Makefile:

tth@gally:/tmp/xfractint-20.04p07$ make
/usr/bin/gcc -I./headers -DXFRACT -DNOBSTRING   -g -DBIG_ANSI_C -DLINUX -O2 -march=pentium -fno-builtin
      -c -o dos_help/hc.o dos_help/hc.c
/usr/bin/gcc -I./headers -DXFRACT -DNOBSTRING   -g -DBIG_ANSI_C -DLINUX -O2 -march=pentium -fno-builtin
      -DSRCDIR=\"/usr/share/xfractint\" -c ./unix/unix.c
/usr/bin/gcc -o hc -I./headers -DXFRACT -DNOBSTRING   -g -DBIG_ANSI_C -DLINUX -O2 -march=pentium -fno-builtin
      ./dos_help/hc.o unix.o
cd ./dos_help; ../hc /c; mv fractint.hlp ..
HC - FRACTINT Help Compiler.

Compiling: help.src
Making hot-links.
Paginating online help.
Paginating document.
Writing: helpdefs.h
I'm waiting a few minutes..., hitting Ctrl-C
make: *** [fractint.hlp] Interrupt

In another xterm:

tth@gally:~$ ps x | grep hc
28504 pts/1    S+     0:00 /bin/sh -c cd ./dos_help; ../hc /c; mv fractint.hlp ..
28505 pts/1    S+     0:00 ../hc /c
tth@gally:~$ strace -p 28505
Process 28505 attached - interrupt to quit
futex(0x80687d0, FUTEX_WAIT, 2, NULL <unfinished ...>

Uh oh, what is this futex ? We need more investigation...

More investigation

Cleaning up the build dirs (with rm -Rf, unpacking tarball, re-make the HC compiler, and running it under strace. (Full trace here)

read(3, "\n\10\3\3\0\0\0\0\0\0\0\0\0\0\0\0 Using Help \3\10\33\3"..., 4096) = 4096
read(3, ".........\n2.26    Orbit Fractals"..., 4096) = 4096
read(3, "...........\n5.8     Image Calcul"..., 4096) = 4096
_llseek(3, 0, [0], SEEK_SET)            = 0
read(3, "\n\10\3\3\0\0\0\0\0\0\0\0\0\0\0\0 Using Help \3\10\33\3"..., 4096) = 4096
_llseek(3, -2953, [1143], SEEK_CUR)     = 0
write(3, "      New Features in 20.4.X...."..., 8192) = 8192
open("/etc/mtab", O_RDONLY)             = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=334, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f74000
read(4, "/dev/hda3 / ext3 rw,errors=remou"..., 4096) = 334
close(4)                                = 0
munmap(0xb7f74000, 4096)                = 0
open("/proc/meminfo", O_RDONLY)         = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f74000
read(4, "MemTotal:       191788 kB\nMemFre"..., 1024) = 598
close(4)                                = 0
munmap(0xb7f74000, 4096)                = 0
open("helpdefs.h", O_RDONLY)            = -1 ENOENT (No such file or directory)
open("helpdefs.h", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
write(1, "Writing: helpdefs.h\n", 20)   = 20
fstat64(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f74000
write(4, "\n/*\n * helpdefs.h\n *\n * Contains"..., 4096) = 4096
write(4, "NZ3D1                      86\n#d"..., 4096) = 4096
futex(0x80687d0, FUTEX_WAIT, 2, NULL)   = -1 EINTR (Interrupted system call)
--- SIGINT (Interrupt) @ 0 (0) ---
+++ killed by SIGINT +++

Nice try. Why this damned software is reading mtab and meminfo ? (Are we in the Glibc ?) Next tool before chain saw: ltrace, maybe, can show us others evidences...

fprintf(0x8072060, "\n")                         = 1
fprintf(0x8072060, "#define %-32s %3d", "INTRO_CREDITS", 186) = 44
strlen("HELP_INDEX")                             = 10
fprintf(0x8072060, "\n")                         = 1
fprintf(0x8072060, "#define %-32s %3d", "RDSKEYS", 187) = 44
strlen("HELP_INDEX")                             = 10
fprintf(0x8072060, "\n")                         = 1
fprintf(0x8072060, "\n\n")                       = 2
fclose(0x8072000 <unfinished ...>
--- SIGINT (Interrupt) ---
+++ killed by SIGINT +++

Hang in a fclose ? Grmbl... But what file are we closing ?

tth@gally:/tmp/xfractint-20.04p07/dos_help$ grep 8072000 ltrace.txt 
fclose(0x8072000 <unfinished ...>
tth@gally:/tmp/xfractint-20.04p07/dos_help$ 

AH AH ! I'm running crazy !