BIC-MNI / minc-toolkit

Metaproject uniting all the available minc tools
GNU General Public License v3.0
37 stars 15 forks source link

Build segfaults on Debian Wheezy 64bit - "double free or corruption" in mincresample #9

Closed carlohamalainen closed 10 years ago

carlohamalainen commented 10 years ago

Hi,

I can't build the minc-toolkit on my Debian Wheezy 64bit VM (it does build fine on another Ubuntu 13.10 VM though).

The error:

Scanning dependencies of target xfm2param
[ 91%] Building C object mni_autoreg/minctracc/CMakeFiles/xfm2param.dir/Extra_progs/xfm2param.c.o
Linking C executable xfm2param
[ 91%] Built target xfm2param
Scanning dependencies of target zscore_vol
[ 92%] Building C object mni_autoreg/minctracc/CMakeFiles/zscore_vol.dir/Extra_progs/zscore_vol.c.o
Linking C executable zscore_vol
[ 92%] Built target zscore_vol
Scanning dependencies of target create_test_data
[ 92%] Generating test.xfm
[ 92%] Generating object1.mnc
[ 92%] Generating object2.mnc
Transforming slices:................................................................Done
Segmentation fault
make[2]: *** [mni_autoreg/Testing/object2.mnc] Error 139
make[1]: *** [mni_autoreg/Testing/CMakeFiles/create_test_data.dir/all] Error 2
make: *** [all] Error 2

If I go into mni_autoreg/Testing I can trigger the segfault and get more details. Turns out there is a "double free or corruption" in mincresample:

$ cd minc-toolkit/build/mni_autoreg/
$ make VERBOSE=1

(lots of output, snipped)

/usr/bin/cmake -E cmake_progress_report /home/carlo/minc-toolkit/build/CMakeFiles
[ 88%] Generating test3.xfm
cd /home/carlo/minc-toolkit/build/mni_autoreg/Testing && ../minctracc/param2xfm -clobber -translation 5 2 -6 -rotation -4 7 10 -scales 1.7 1.7 1.7 /home/carlo/minc-toolkit/build/mni_autoreg/Testing/test3.xfm
/usr/bin/cmake -E cmake_progress_report /home/carlo/minc-toolkit/build/CMakeFiles
[ 88%] Generating ellipse3.mnc
cd /home/carlo/minc-toolkit/build/mni_autoreg/Testing && ../../minctools/progs/mincresample -clobber -transformation /home/carlo/minc-toolkit/build/mni_autoreg/Testing/test3.xfm -like /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse0.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse0.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse3.mnc
Transforming slices:................................................................Done
/usr/bin/cmake -E cmake_progress_report /home/carlo/minc-toolkit/build/CMakeFiles
[ 88%] Generating ellipse4.mnc
cd /home/carlo/minc-toolkit/build/mni_autoreg/Testing && ../../minctools/progs/mincresample -clobber -xdircos 0.891006529493696 0 0.453990489327253 -ydircos 0 1 0 -zdircos -0.453990489327253 0 0.891006529493696 /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse0.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse4.mnc
Transforming slices:................................................................Done
/usr/bin/cmake -E cmake_progress_report /home/carlo/minc-toolkit/build/CMakeFiles
[ 88%] Generating warped_ellipse4.mnc
cd /home/carlo/minc-toolkit/build/mni_autoreg/Testing && ../../minctools/progs/mincmath /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse0.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse_tmp1.mnc -mult -constant 4.5 -clob
Processing:................................................................Done
cd /home/carlo/minc-toolkit/build/mni_autoreg/Testing && ../../minctools/progs/mincresample -clobber -transformation /home/carlo/minc-toolkit/mni_autoreg/Testing/tps.xfm -like /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse0.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/ellipse_tmp1.mnc /home/carlo/minc-toolkit/build/mni_autoreg/Testing/warped_ellipse4.mnc
Transforming slices:................................................................Done
*** glibc detected *** ../../minctools/progs/mincresample: double free or corruption (!prev): 0x00000000016207a0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x76d76)[0x2b5e6e149d76]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x2b5e6e14eaac]
/home/carlo/minc-toolkit/build/libminc/libminc2.so.3.0.0(H5FL_garbage_coll+0x6c)[0x2b5e6d75abec]
/home/carlo/minc-toolkit/build/libminc/libminc2.so.3.0.0(H5FL_term_interface+0x9)[0x2b5e6d75c009]
/home/carlo/minc-toolkit/build/libminc/libminc2.so.3.0.0(+0xecbf5)[0x2b5e6d6f7bf5]
/lib/x86_64-linux-gnu/libc.so.6(+0x36df2)[0x2b5e6e109df2]
/lib/x86_64-linux-gnu/libc.so.6(+0x36e45)[0x2b5e6e109e45]
../../minctools/progs/mincresample[0x40279f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x2b5e6e0f1ead]
../../minctools/progs/mincresample[0x402629]
======= Memory map: ========
00400000-00411000 r-xp 00000000 ca:01 2625526                            /home/carlo/minc-toolkit/build/minctools/progs/mincresample
00610000-00612000 rw-p 00010000 ca:01 2625526                            /home/carlo/minc-toolkit/build/minctools/progs/mincresample
01606000-0172a000 rw-p 00000000 00:00 0                                  [heap]
2b5e6d3e9000-2b5e6d409000 r-xp 00000000 ca:01 393757                     /lib/x86_64-linux-gnu/ld-2.13.so
2b5e6d409000-2b5e6d40b000 rw-p 00000000 00:00 0
2b5e6d608000-2b5e6d609000 r--p 0001f000 ca:01 393757                     /lib/x86_64-linux-gnu/ld-2.13.so
2b5e6d609000-2b5e6d60a000 rw-p 00020000 ca:01 393757                     /lib/x86_64-linux-gnu/ld-2.13.so
2b5e6d60a000-2b5e6d60b000 rw-p 00000000 00:00 0
2b5e6d60b000-2b5e6d9e2000 r-xp 00000000 ca:01 2625175                    /home/carlo/minc-toolkit/build/libminc/libminc2.so.2.3.00
2b5e6d9e2000-2b5e6dbe1000 ---p 003d7000 ca:01 2625175                    /home/carlo/minc-toolkit/build/libminc/libminc2.so.2.3.00
2b5e6dbe1000-2b5e6dc3c000 rw-p 003d6000 ca:01 2625175                    /home/carlo/minc-toolkit/build/libminc/libminc2.so.2.3.00
2b5e6dc3c000-2b5e6dc44000 rw-p 00000000 00:00 0
2b5e6dc4c000-2b5e6dc4d000 rw-p 00000000 00:00 0
2b5e6dc4d000-2b5e6dcce000 r-xp 00000000 ca:01 393330                     /lib/x86_64-linux-gnu/libm-2.13.so
2b5e6dcce000-2b5e6decd000 ---p 00081000 ca:01 393330                     /lib/x86_64-linux-gnu/libm-2.13.so
2b5e6decd000-2b5e6dece000 r--p 00080000 ca:01 393330                     /lib/x86_64-linux-gnu/libm-2.13.so
2b5e6dece000-2b5e6decf000 rw-p 00081000 ca:01 393330                     /lib/x86_64-linux-gnu/libm-2.13.so
2b5e6decf000-2b5e6ded1000 r-xp 00000000 ca:01 393326                     /lib/x86_64-linux-gnu/libdl-2.13.so
2b5e6ded1000-2b5e6e0d1000 ---p 00002000 ca:01 393326                     /lib/x86_64-linux-gnu/libdl-2.13.so
2b5e6e0d1000-2b5e6e0d2000 r--p 00002000 ca:01 393326                     /lib/x86_64-linux-gnu/libdl-2.13.so
2b5e6e0d2000-2b5e6e0d3000 rw-p 00003000 ca:01 393326                     /lib/x86_64-linux-gnu/libdl-2.13.so
2b5e6e0d3000-2b5e6e253000 r-xp 00000000 ca:01 393333                     /lib/x86_64-linux-gnu/libc-2.13.so
2b5e6e253000-2b5e6e453000 ---p 00180000 ca:01 393333                     /lib/x86_64-linux-gnu/libc-2.13.so
2b5e6e453000-2b5e6e457000 r--p 00180000 ca:01 393333                     /lib/x86_64-linux-gnu/libc-2.13.so
2b5e6e457000-2b5e6e458000 rw-p 00184000 ca:01 393333                     /lib/x86_64-linux-gnu/libc-2.13.so
2b5e6e458000-2b5e6e45f000 rw-p 00000000 00:00 0
2b5e6e467000-2b5e6e47c000 r-xp 00000000 ca:01 393758                     /lib/x86_64-linux-gnu/libgcc_s.so.1
2b5e6e47c000-2b5e6e67c000 ---p 00015000 ca:01 393758                     /lib/x86_64-linux-gnu/libgcc_s.so.1
2b5e6e67c000-2b5e6e67d000 rw-p 00015000 ca:01 393758                     /lib/x86_64-linux-gnu/libgcc_s.so.1
2b5e70000000-2b5e70021000 rw-p 00000000 00:00 0
2b5e70021000-2b5e74000000 ---p 00000000 00:00 0
7fff6552d000-7fff65551000 rw-p 00000000 00:00 0                          [stack]
7fff655ff000-7fff65600000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted
make[2]: *** [mni_autoreg/Testing/warped_ellipse4.mnc] Error 134
make[2]: Leaving directory `/home/carlo/minc-toolkit/build'
make[1]: *** [mni_autoreg/Testing/CMakeFiles/create_test_data.dir/all] Error 2
make[1]: Leaving directory `/home/carlo/minc-toolkit/build'
make: *** [all] Error 2
vfonov commented 10 years ago

Can't reproduce this on my VM what are your configuration options ? Are you using system-supplied libraries or building everything internally?

carlohamalainen commented 10 years ago

I installed a minimal Debian Wheezy 64bit system, then added these packages:

sudo apt-get install cmake cmake-curses-gui
sudo apt-get install \
             build-essential g++ \
             cmake cmake-curses-gui \
             bison flex \
             freeglut3 freeglut3-dev \
             libxi6 libxi-dev libxmu6 libxmu-dev libxmu-headers

Cloned the repo, etc:

git clone --recursive git://github.com/BIC-MNI/minc-toolkit.git minc-toolkit
cd minc-toolkit
rm -fr build
mkdir build
cd build

ccmake ..  # hit 'c'
           # go down to MT_BUILD_SHARED_LIBS, hit enter to turn 'ON'
           # hit 'c'
           # hit 'g'
           #
make &> make.log

So changing MT_BUILD_SHARED_LIBS was the only thing that I did differently. I need this option to get pyminc to work.

Also I can't reproduce this on my Debian Wheezy laptop (Lenovo Carbon X1), it all builds fine.

Maybe dodgy ram on my Amazon VM? Or something to do with the CPU architecture?

$ cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 44
model name  : Intel(R) Xeon(R) CPU           E5645  @ 2.40GHz
stepping    : 2
microcode   : 0x13
cpu MHz     : 1999.975
cache size  : 12288 KB
physical id : 0
siblings    : 1
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 50
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc up rep_good nopl nonstop_tsc pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 popcnt aes hypervisor lahf_lm
bogomips    : 3999.95
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
vfonov commented 10 years ago

how much memory does VM have ?

carlohamalainen commented 10 years ago

1.7Gb, should be enough? I'll try building again with some swap space enabled. The other VM where it built ok has only 600Mb of ram and no swap.

carlohamalainen commented 10 years ago

I can replicate the segfault in a VirtualBox VM on my laptop. I could export the VM to an ova file if you want to try it yourself.

vfonov commented 10 years ago

ok, let's try

carlohamalainen commented 10 years ago

OK, I've emailed you a url to the VirtualBox ova file.

vfonov commented 10 years ago

ok, thank you I found the bug and fixed it : https://github.com/BIC-MNI/minc-tools/commit/f5d91cb16fcf7b82f43816cc5f4264fb4103c843

carlohamalainen commented 10 years ago

Great, can confirm that it now builds without errors on my Amazon EC2 instance.

Thanks.