STRUCTURE CRASHES: "munmap_chunck() error - invalid pointer" during run with USEPOPINFO model. - MEMORY ASSIGNMENT ISSUE - how to avoid/fix?

47 views
Skip to first unread message

Moshe Jasper

unread,
Nov 7, 2019, 9:11:37 PM11/7/19
to structure-software
Hi, 

I'm running STRUCTURE 2.3.4 on an ubuntu server (Ubuntu 14.04.5 LTS, id_like = Debian) via commandline, attempting to infer ancestry of (hybridised) descendants from known ancestry groups (an Australian mammal)

Strategy was to infer population of origin for a group of ancestors (worked fine), then (in a second structure run) use these predefined ancestor groups to assign admixture proportions to descendants. (i.e. the USEPOPINFO model)
Data setup for second step was 3 ancestral populations (coded 1-3) with POPFLAG set to 1, followed by other individuals with POPFLAG set to 0. 

During this second step, at random points within the first 20k iterations, runs will abor with the error message "error in '[path]/structure': munmap_chunk(): invalid pointer: 0x08735ba8 ***" [or similar pointer]

How do I avoid this? Is it an issue at my end, or something wrong with the USEPOPINFO feature? (either in terms of my system or elsewhere). 

Example main parameters: 

#define MAXPOPS 3
#define BURNIN 10000
#define NUMREPS 100000
#define INFILE 2012.sort.str.txt
#define OUTFILE 2012_results
#define NUMINDS 56
#define NUMLOCI 14522
#define ONEROWPERIND 1
#define LABEL 1
#define POPDATA 1
#define POPFLAG 1
#define LOCDATA 0
#define PHENOTYPE 0
#define EXTRACOLS 0
#define MARKERNAMES 0
#define RECESSIVEALLELES 0
#define MAPDISTANCES 0


Example extra parameters

#define NOADMIX 0
#define USEPOPINFO 1
#define MIGRPRIOR 0
#define LOCPRIOR 0
#define FREQSCORR 1
#define ONEFST 0
#define INFERALPHA 1
#define INFERLAMBDA 0
#define LAMBDA 0.25
#define GENSBACK 4
#define PFROMPOPFLAGONLY 1
#define LOCISPOP 1
#define PRINTLAMBDA 0
#define RANDOMIZE 0
#define INTERMEDSAVE 10

(note that randomize is set to zero as I am running these parallel on a cluster and using a python script to assign a unique seed to each sample). 

Data mockup (some individuals given with 2 loci)

(no column labels supplied (dealt with in main parameters)... columns are (1) individuals, (2) population label, (3) popflag, (4,5) allele 1 (onerowperindv is on), (6,7) allele 2, etc. )

8714   1   1   100   100   120   120
8738   1   1   100   100   120   120
279    1   1   -9    -9    120   120
7331   2   1   100   100   120   110
7343   2   1   100   100   120   120
8391   2   1   -9    -9    110   110
932    3   1   130   130   120   120
933    3   1   130   130   120   120
703    3   1   100   100   120   120
8895   4   0   100   100   120   120
981    4   0   100   100   120   120
8661   5   0   100   100   120   120



Implementation

Server: Ubuntu version 14.04.5 ("LTS, Trusty Tahr") 
ID=ubuntu
ID_LIKE=debian

Structure version is 2.3.4. 
SLURM version is 2.6.5
Python3 version is 3.6.3 (recently installed - default for OS 3.4)

I am running a series of structure jobs in parallel on a slurm system via the srun command (srun job1 & srun job2 & srun job3; wait) format. These various sruns (carrying the structure process) abort at different times (in response to structure crashing) with the message, srun: error: master: task 0: Aborted (core dumped)
I am open to this being a filesize issue: however, I have successfully completed a structure run with different inference parameters (admix, not locprior model) without core dump on a much larger file, so suspect a model-specific issue... 
STRUCTURE initially wasn't recognized on my operating system as it is 32 bit - I dealt with this via sudo apt-get install then the libraries lib32z1, lib32ncurses5, & lib32bz2-1.0
Lambda is set to 0.25 based on prior inference (I'm using SNPs, thinned, with singletons removed)

My rationale for using the settings that given in the Manual (page 11,  under the heading, "USEPOPINFO model: pre-specify the population of origin of some individuals to assist ancestry estimation for individuals of unknown origin") with the goal of classifying individuals of unknown origin based on a prior set of individuals of known origin (groups 1-3). 

Moshe Jasper

unread,
Nov 7, 2019, 11:35:49 PM11/7/19
to structure-software
UPDATE: I have downsampled my original data to contain only 56 individuals and 500 SNPs and the error continues to occur (again, at a seemingly random frequency proportional to overall processing done rather than anything else). 

(at this frequency several runs were able to complete through to 100k iterations, though a couple still crashed with the same error - making me think there is some kind of underlying inconsistency in the code for this model). 
But I don't think it is due to file size (though this increases the frequency). 
Again, running with other parameters (e.g. standard ADMIXTURE) doesn't trigger this error. 

Vikram Chhatre

unread,
Nov 7, 2019, 11:39:24 PM11/7/19
to structure-software
This question is better posed to your sysadmin if you are working on a HPC.  If not, then perhaps search stackoverflow (also see this: https://stackoverflow.com/questions/32118545/munmap-chunk-invalid-pointer).

Alternatively, try running your analysis on a Macintosh to see if you can replicate the problem.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/structure-software/f48bb0cb-47bb-4a51-89c9-30e762d1a39d%40googlegroups.com.

Moshe Jasper

unread,
Nov 8, 2019, 8:58:38 AM11/8/19
to structure-software
I've had a look at the readily available stackoverflows for the munmap issue previously - what seems quite clear from them is that they are C language errors (not something I've been touching - my scripting work has been entirely in python & bash). 
This also makes me suspect it's an internal issue with STRUCTURE
To unsubscribe from this group and stop receiving emails from it, send an email to structure-software+unsub...@googlegroups.com.

Moshe Jasper

unread,
Nov 9, 2019, 10:06:58 AM11/9/19
to structure-software
We've fixed the problem - solution and  possible reasons included below in case someone else runs into trouble with USEPOPINFO in the future. 

We were (a) running a 32-bit version of STRUCTURE (the pre-compiled linux command-line one, available from the website) with patches to make it work on a 64-bit system, 
and (b) running the initial compiled release of 2.3.4, which has a known issue related to memory in another module that has been patched. 

To resolve, we downloaded and recompiled the patched version for 64-bit. (linkage model patch, https://web.stanford.edu/group/pritchardlab/structure_software/release_versions/v2.3.4/html/structure-linkagemodel-patch.c ) This version, described as resolving a memory misallocation error in the Linkage model, also seems to resolve ours (also a memory misallocation error) in the USEPOPINFO model. 

Regards

(the structure known issues page from where we got this: (structure.c) is here: https://web.stanford.edu/group/pritchardlab/structure_software/release_versions/v2.3.4/html/known_issues.html )

Francisco Pina Martins

unread,
Nov 15, 2019, 5:41:25 AM11/15/19
to structure-software
Thank you for the detailed solution to the problem. This is bound to happen again and your post will certainly help others!

Best,

Francisco
Reply all
Reply to author
Forward
0 new messages