free(): invalid pointer with lefse command

Hi,

I’m seeing the occasional but reproducible crash using a lefse command like this:

mothur > lefse(shared=current, design=abc123.design)
Using abc123.shared as input file for the shared parameter.

You did not provide a class, using abc123.

0.03

Number of significantly discriminative features: 23 ( 81 ) before internal wilcoxon.
*** Error in `mothur’: free(): invalid pointer: 0x0000000001e4dcd0 ***
Aborted

The crash can be triggered with certain combinations of input data and seed parameter (as in set.seed() ) and whether or not I run mothur under gdb. So in practice I can avoid the crash by trying different seed parameters but when I run a batch, say, containing twenty or so lefse commands, among others, crashes become rather likely. This happens with the non-MPI Linux 1.36.1 mothur version, the downloaded pre-compiled one as well the binary Debian version. Mothur 1.33.3 as shipped by Debian jessie is also affected. The following stack-trace was made with mothur 1.36.1 Debian source package re-compiled with -Og -g flags, I hope that helps:

*** Error in `/home/$USER/src/mothur-1.36.1/mothur’: free(): invalid pointer: 0x0000000001bc4400 ***

Program received signal SIGABRT, Aborted.
0x00007ffff6d72107 in __GI_raise (sig=sig@entry=6) at …/nptl/sysdeps/unix/sysv/linux/raise.c:56
56 …/nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff6d72107 in __GI_raise (sig=sig@entry=6) at …/nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff6d734e8 in __GI_abort () at abort.c:89
#2 0x00007ffff6db0214 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff6ea3000 “*** Error in `%s’: %s: 0x%s ***\n”) at …/sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff6db59ee in malloc_printerr (action=1, str=0x7ffff6e9f0be “free(): invalid pointer”, ptr=) at malloc.c:4996
#4 0x00007ffff6db66f6 in _int_free (av=, p=, have_lock=0) at malloc.c:3840
#5 0x0000000000512330 in __gnu_cxx::new_allocator::deallocate (__p=, this=0x7fffffffb700) at /usr/include/c++/5/ext/new_allocator.h:110
#6 __gnu_cxx::__alloc_traits<std::allocator >::deallocate (__n=, __p=, __a=…) at /usr/include/c++/5/ext/alloc_traits.h:185
#7 std::_Vector_base<double, std::allocator >::_M_deallocate (__n=, __p=, this=0x7fffffffb700) at /usr/include/c++/5/bits/stl_vector.h:178
#8 std::_Vector_base<double, std::allocator >::~_Vector_base (this=0x7fffffffb700, __in_chrg=) at /usr/include/c++/5/bits/stl_vector.h:160
#9 std::vector<double, std::allocator >::~vector (this=0x7fffffffb700, __in_chrg=) at /usr/include/c++/5/bits/stl_vector.h:425
#10 LinearAlgebra::svd (this=this@entry=0x7fffffffb870, a=std::vector of length 38, capacity 57 = {…}, w=std::vector of length 3, capacity 50 = {…}, v=std::vector of length 3, capacity 57 = {…})
at source/linearalgebra.cpp:2364
#11 0x0000000000513bc0 in LinearAlgebra::lda (this=this@entry=0x7fffffffbf60, a=std::vector of length 50, capacity 64 = {…}, groups=std::vector of length 57, capacity 57 = {…},
means=std::vector of length 3, capacity 3 = {…}, ignore=@0x7fffffffbf5b: true) at source/linearalgebra.cpp:2283
#12 0x0000000000acb8f9 in LefseCommand::lda (this=this@entry=0x152a3e0, adjustedLookup=std::vector of length 50, capacity 64 = {…}, rand_s=std::vector of length 57, capacity 57 = {…},
indexToClass=std::map with 86 elements = {…}, classes=std::vector of length 3, capacity 3 = {…}) at source/commands/lefsecommand.cpp:901
#13 0x0000000000ace3e4 in LefseCommand::testLDA (this=this@entry=0x152a3e0, lookup=std::vector of length 86, capacity 86 = {…}, bins=std::map with 50 elements = {…},
class2GroupIndex=std::map with 3 elements = {…}, subClass2GroupIndex=std::map with 3 elements = {…}) at source/commands/lefsecommand.cpp:801
#14 0x0000000000acf7fd in LefseCommand::process (this=this@entry=0x152a3e0, lookup=std::vector of length 86, capacity 86 = {…}, designMap=…) at source/commands/lefsecommand.cpp:436
#15 0x0000000000ad06db in LefseCommand::execute (this=0x152a3e0) at source/commands/lefsecommand.cpp:296
#16 0x0000000000555d9f in BatchEngine::getInput (this=0x140f590) at source/engine.cpp:340
#17 0x00000000005515d3 in main (argc=, argv=) at source/mothur.cpp:255
(gdb)

Let me know if I need to provide other info.

Thanks
–Robert

Could you send your input files to mothur.bugs@gmail.com?