Re: [structure-group] Memory freeing problem in Structure 2.3.4 under Ubuntu

321 views
Skip to first unread message

Pall Melsted

unread,
Mar 4, 2013, 11:59:33 AM3/4/13
to structure...@googlegroups.com
Hi Rafal

You can email me the files and I'll take a look at it. I'm assuming
you have compiled from source for the 64-bit linux system.

Best regards,
Pall Melsted

On Mon, Mar 4, 2013 at 9:54 AM, Rafal Mostowy <rafal....@gmail.com> wrote:
> I have a very peculiar problem in the newest version of STRUCTURE when
> running under Ubuntu 12.10. Based on what I've tested so far, this problem
> occurs only under the linkage model with a large number of loci (at least
> 1000) and when populations of origin are inferred site-by-site.
>
> The problem is the following: when the program is finishing the console
> returns an output "segmentation fault (core dumped)" and the end of the
> output_ss file is truncated (always a number of loci missing for the last
> sequence).
>
> I tried to look into the source file to identify the problem because it
> seems that it has something to do with memory freeing. Indeed, I noticed
> that the when I comment out the line no 196-200 in the file 'structure.c'
> then the error message disappears. So it seems the problem is with the
> memory allocation of objects: double *R, *sumR and *varR, or rather freeing
> them.
>
> I have tested this problem on another linux computer (i.e., a linux-based
> bioinformatics cluster at my University) and the result was identical. I
> have no idea why this occurs but extensive googling suggests that I'm the
> only one who has this problem.
>
> Oh, and interestingly, when I don't free double* R I get a more precise
> memory freeing error, which I have uploaded to this email (error1.txt). I'm
> also uploading all the files which are causing error (mainparams,
> extraparams, cpsABCDE.dat). The command I used was:
> ./structure -i cpsABCDE.dat
> ----- UPDATE ----- I tried attaching files to this email but I keep getting
> error #340 so I discarded them. I'm happy to email them directly to whoever
> is kind enough to try to help me. Thanks!
>
> I just want to emphasise that this problem doesn't occur on my Mac OS X,
> although I haven't compiled the C code explicitly, and the pre-compiled
> programme doesn't work on my Linux. The kernel I'm using is 3.5.0-25-generic
> and it's a 64 bit computer (x86_64).
>
> I'd appreciate any insight into this problem!
>
> Thanks,
> Rafal
>
> --
> You received this message because you are subscribed to the Google Groups
> "structure-software" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to structure-softw...@googlegroups.com.
> To post to this group, send email to structure...@googlegroups.com.
> Visit this group at http://groups.google.com/group/structure-software?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Adii_ (Institute of Genetics and Animal Breeding)

unread,
Mar 4, 2013, 3:25:28 PM3/4/13
to structure...@googlegroups.com
If You send me files I do some tests on my linux clusters. 

Interesting issue anyway :)

Best regard, or as we say in Poland ' powodzenia ',
Adii_ 


Dan Skelly

unread,
Jul 9, 2013, 3:55:21 PM7/9/13
to structure...@googlegroups.com
Hi,

I seem to be having the same problem as Rafal wrote about in this (several months old) thread. Specifically, I am running STRUCTURE 2.3.4 using the linkage model and outputting site-by-site. I have tested this on systems running Ubuntu 12.04, Ubuntu 10.04, and Scientific Linux 6.4, and the error is the same on all. The error occurs whether I compile from source or use the Linux pre-compiled executable.

The problem is the same as what Rafal reported: when the program is finishing the console reports "segmentation fault (core dumped)" or just "segmentation fault" and the end of output_ss is truncated, with either a number of loci missing for the last individual or the last few individuals. On all systems the output truncates at exactly the same spot. Rafal reported that this only occurs when running STRUCTURE with a large number of loci (>1000), but I've been able to get this issue to reproduce with small numbers of both individuals (~20) and loci (~50). 

I followed Rafal's suggestion and commented out the following lines in structure.c:
  //free (R);
  //free (sumR);
  //free (varR);
(This was lines 186-188 in the source code I downloaded). After re-compiling and re-running, I get an error (see below), but output_ss is no longer truncated.

Anyone have any ideas what might be going on? Obviously this is related to memory allocation but I can't pinpoint it any further. I attached an example structure input file along with the mainparams and extraparams. This is set up for a (very) quick run that reproduces the error on my machines. This input file contains 21 individuals and 48 loci.

Thanks for any help you might provide,
Dan


The error that shows up after commenting out 3 lines in structure.c and re-compiling:
*** glibc detected *** ./structure: free(): invalid pointer: 0x000000000083f520 ***
======= Backtrace: =========
/lib/libc.so.6(+0x78bb6)[0x7faa6aa05bb6]
/lib/libc.so.6(cfree+0x73)[0x7faa6aa0c483]
./structure[0x40214f]
./structure[0x40edc0]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7faa6a9abc4d]
./structure[0x4010b9]
======= Memory map: ========
00400000-00423000 r-xp 00000000 00:16 186130050
[much more ...]
example.stru
extraparams.txt
mainparams_example.txt

Pall Melsted

unread,
Jul 10, 2013, 9:11:43 AM7/10/13
to structure-software
Hi Dan

Thanks for your data. I've been able to reproduce this on linux, although it doesn't occur on the mac.

The bug is in InitializeR, lines 600-601 or so. You can fix it by commenting

//sumR[ind] = 0.0;
//varR[ind] = 0.0;

which just happen to write over important information necessary to free the next vector, which is R, this is why the bug happens in free(R) at the end.

- Pall



--
You received this message because you are subscribed to the Google Groups "structure-software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structure-softw...@googlegroups.com.
To post to this group, send email to structure...@googlegroups.com.

Dan Skelly

unread,
Jul 10, 2013, 3:53:39 PM7/10/13
to structure...@googlegroups.com
Thank you Pall, it is working flawlessly now!

Best,
Dan
To unsubscribe from this group and stop receiving emails from it, send an email to structure-software+unsub...@googlegroups.com.

To post to this group, send email to structure...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages