# free(): invalid pointer with lefse command

**URL:** <https://forum.mothur.org/t/free-invalid-pointer-with-lefse-command/2616>\
**Category:** mothur bugs\
**Created:** [December 1, 2015, 10:16pm UTC](https://forum.mothur.org/t/free-invalid-pointer-with-lefse-command/2616 "2015-12-01T22:16:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skruCn](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@skruCn](https://forum.mothur.org/u/skruCn)\
**Post date:** [December 1, 2015, 10:16pm UTC](https://forum.mothur.org/t/free-invalid-pointer-with-lefse-command/2616/1 "2015-12-01T22:16:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![westcott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/westcott/32/18_2.png) [@westcott](https://forum.mothur.org/u/westcott)\
**Post date:** [December 3, 2015, 2:56pm UTC](https://forum.mothur.org/t/free-invalid-pointer-with-lefse-command/2616/2 "2015-12-03T14:56:04Z")

</div>

Could you send your input files to [mothur.bugs@gmail.com](mailto:mothur.bugs@gmail.com)?
