Skip to content

Segmentation fault in Linux server #533

@xliaoyi

Description

@xliaoyi

Hi,

I encountered a “Segmentation fault” error when running SLiM on my Linux server. The issue seems to be caused by the following line in my SLiM script:

sim.setValue("next_mut_time", asInteger(round(sim.getValue("next_mut_time") + rexp(1, p1.individualCount * 2 * 2 * SD_len * (IGC_RATE + alpha*3)))) + 1);

Removing this line allows SLiM to run successfully on the Linux server. Interestingly, the same code runs without any issues on my Mac, even with this line included.

I’ve attached the relevant details below, including the Linux server version, backtrace, and a minimal reproducible example. In the example, I reduced the number of generations to 30 and the population size to 15, the segmentation fault still occurs, regardless of the seed. However, when I reduce the generations or population size further—say to 10—the error no longer occurs.

Please let me know if any information you need is still missing.

Thank you so much for your help!

Best,
Luis

Linux version
NAME="Rocky Linux"
VERSION="8.10 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.10"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.10 (Green Obsidian)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2029-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8"
ROCKY_SUPPORT_PRODUCT_VERSION="8.10"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.10"

Backtrace
(gdb) bt
#0 0x0000153781316891 in free () from /usr/lib64/libc.so.6
#1 0x00000000008c2dba in __gnu_cxx::new_allocator::deallocate (__p=, this=0x243c140) at /usr/include/c++/8/ext/new_allocator.h:116
#2 std::allocator_traits<std::allocator >::deallocate (__n=, __p=, __a=...) at /usr/include/c++/8/bits/alloc_traits.h:462
#3 std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_destroy (__size=, this=0x243c140)
at /usr/include/c++/8/bits/basic_string.h:230
#4 std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_dispose (this=0x243c140) at /usr/include/c++/8/bits/basic_string.h:225
#5 std::__cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string (this=0x243c140, __in_chrg=)
at /usr/include/c++/8/bits/basic_string.h:661
#6 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > (__pointer=0x243c140) at /usr/include/c++/8/bits/stl_construct.h:98
#7 std::_Destroy_aux::__destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator >> (__last=, __first=0x243c140)
at /usr/include/c++/8/bits/stl_construct.h:108
#8 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator >
> (__last=, __first=)
at /usr/include/c++/8/bits/stl_construct.h:137
#9 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator >*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > (__last=0x25bdd80, __first=) at /usr/include/c++/8/bits/stl_construct.h:206
#10 std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::~vector (this=0x1cf6ff8, __in_chrg=) at /usr/include/c++/8/bits/stl_vector.h:567
#11 EidosValue_String::~EidosValue_String (this=0x1cf6fe0, __in_chrg=) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_value.h:644
#12 0x00000000007eea14 in Eidos_intrusive_ptr_release (p_value=0x1cf6fe0) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_value.h:401
#13 Eidos_intrusive_ptr::~Eidos_intrusive_ptr (this=, __in_chrg=)
at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_intrusive_ptr.h:115
#14 Eidos_intrusive_ptr::reset (this=0x1e67020) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_intrusive_ptr.h:153
#15 EidosSymbolTable::~EidosSymbolTable (this=0x7ffe56603fd0, __in_chrg=) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_symbol_table.cpp:219
#16 0x0000000000420966 in Community::ExecuteEidosEvent (this=this@entry=0x1dc32d0, p_script_block=0x1e4fe70) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_interpreter.h:136
#17 0x0000000000426774 in Community::_RunOneTickWF (this=this@entry=0x1dc32d0) at /work/09059/xliaoyi/ls6/software/SLiM/core/community.cpp:2798
#18 0x00000000004271ee in Community::_RunOneTick (this=this@entry=0x1dc32d0) at /work/09059/xliaoyi/ls6/software/SLiM/core/community.cpp:2255
#19 0x000000000042720f in Community::RunOneTick (this=this@entry=0x1dc32d0) at /work/09059/xliaoyi/ls6/software/SLiM/core/community.cpp:2137
#20 0x0000000000497397 in main (argc=, argv=) at /work/09059/xliaoyi/ls6/software/SLiM/core/main.cpp:760

(gdb) run sim_igc.slim
Starting program: /work/09059/xliaoyi/ls6/software/build/slim sim_igc.slim
BFD: warning: /work2/09059/xliaoyi/ls6/software/miniconda/lib/libstdc++.so.6: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
BFD: warning: /work2/09059/xliaoyi/ls6/software/miniconda/lib/libstdc++.so.6: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
// Initial random seed:
7377046572099460671

// RunInitializeCallbacks():
initializeSLiMModelType(modelType = 'WF');
initializeSLiMOptions(nucleotideBased = T);
initializeMutationTypeNuc(1, 0.5, "n", 0, 0.001);
initializeMutationTypeNuc(0, 0.5, "f", 0);
initializeGenomicElementType(1, c(m0, m1), c(0.8, 0.2));
initializeGenomicElementType(0, m0, 1);
initializeGenomicElement(g0, 0, 9999);
initializeGenomicElement(g1, 10000, 19999);
initializeGenomicElement(g0, 20000, 29999);
initializeGenomicElement(g1, 30000, 39999);
initializeGenomicElement(g0, 40000, 49999);
initializeAncestralNucleotides("CCTGCAGTCGTGTGGACTCC...");
initializeRecombinationRate(1.2e-08);

// Starting run at tick :
1

Using IGC

Program received signal SIGSEGV, Segmentation fault.
0x0000155554811891 in free () from /usr/lib64/libc.so.6
(gdb) where
#0 0x0000155554811891 in free () from /usr/lib64/libc.so.6
#1 0x00000000004bde11 in EidosValue_String::~EidosValue_String() ()
#2 0x00000000008344ce in EidosSymbolTable::~EidosSymbolTable() ()
#3 0x00000000004c49e1 in Community::ExecuteEidosEvent(SLiMEidosBlock*) ()
#4 0x00000000004ca3dc in Community::_RunOneTickWF() ()
#5 0x00000000004cb267 in Community::_RunOneTick() ()
#6 0x00000000004a69a8 in main ()

Minimal reproducible example

initialize() {	if (exists("slimgui")) {	defineConstant("IGC_RATE", 2.5e-7);	defineConstant("alpha", 1.3e-8/3);	defineConstant("SD_len", 10000);	defineConstant("N", 15);	defineConstant("IGC", T);	defineConstant("GEN", 30);	defineConstant("SEED", 1);	}	if (!exists("IGC_RATE")) defineConstant("IGC_RATE", 2.5e-7);	if (!exists("alpha")) defineConstant("alpha", 1.3e-8/3);	if (!exists("SD_len")) defineConstant("SD_len", 10000);	if (!exists("N")) defineConstant("N", 15);	if (!exists("IGC")) defineConstant("IGC", T);	if (!exists("GEN")) defineConstant("GEN", 30);	if (!exists("SEED")) defineConstant("SEED", 1);	initializeSLiMModelType("WF");	initializeSLiMOptions(nucleotideBased=T);	setSeed(SEED);	//	initializeTreeSeq();	initializeMutationTypeNuc("m1", 0.5, "n", 0.0, 0.001); // may need to be changed	initializeMutationTypeNuc("m0", 0.5, "f", 0.0);	initializeGenomicElementType("g1", c(m0, m1), c(0.8, 0.2), mmJukesCantor(alpha));	initializeGenomicElementType("g0", m0, 1, mmJukesCantor(alpha));	initializeGenomicElement(g0, 0, SD_len-1);	initializeGenomicElement(g1, SD_len, 2*SD_len-1);	initializeGenomicElement(g0, 2*SD_len, 3*SD_len-1);	initializeGenomicElement(g1, 3*SD_len, 4*SD_len-1);	initializeGenomicElement(g0, 4*SD_len, 5*SD_len-1);	sd = randomNucleotides(SD_len);	seq = randomNucleotides(SD_len) + sd + randomNucleotides(SD_len) + sd + randomNucleotides(SD_len);	initializeAncestralNucleotides(seq);	initializeRecombinationRate(1.2e-8); } 1 early() {	sim.addSubpop("p1", N);	sim.setValue("next_mut_time", 1);	if (IGC) {	catn("Using IGC");	} else {	catn("Using no IGC");	} } 1:GEN late() {	if (sim.cycle % 10000 == 0) {	catn("Generation: " + sim.cycle + " / " + GEN);	}	if (IGC) {	//	catn("next_mut_time = " + sim.getValue("next_mut_time"));	if (sim.cycle == sim.getValue("next_mut_time")) {	if (runif(1) < IGC_RATE/(IGC_RATE + alpha*3)) {	// catn("IGC happening at t = " + sim.cycle);	// sample a haplotype	ind = p1.sampleIndividuals(1); // To check	hap = ifelse(runif(1) < 0.5, ind.haploidGenome1, ind.haploidGenome2);	igc_tract_len = rgeom(1, 1/250); // Harpak et al., PNAS 2017	left_tract_len = runif(1) * igc_tract_len;	right_tract_len = igc_tract_len - left_tract_len;	mid_coord = round(runif(1, SD_len + left_tract_len + 1, 2*SD_len - right_tract_len - 1)); // make sure IGC tract inside the SD	donor_start = asInteger(SD_len + mid_coord - left_tract_len - 1);	donor_end = asInteger(SD_len + mid_coord + right_tract_len - 1);	acceptor_start = asInteger(3*SD_len + mid_coord - left_tract_len - 1);	acceptor_end = asInteger(3*SD_len + mid_coord + right_tract_len - 1);	genome = hap.nucleotides(format="char");	// choose acceptor paralog	if (runif(1) < 0.5) {	// first paralog is acceptor	genome[donor_start:donor_end] = genome[acceptor_start:acceptor_end];	} else {	// swap donor and acceptor	genome[acceptor_start:acceptor_end] = genome[donor_start:donor_end];	}	}	// next time point igc will happens	sim.setValue("next_mut_time", asInteger(round(sim.getValue("next_mut_time") +	rexp(1, p1.individualCount * 2 * 2 * SD_len * (IGC_RATE + alpha*3)))) + 1);	}	} } GEN+1 late() {	date = date();	muts = sim.mutations;	// Count fixed mutations	N_m1_fixed = size(sim.substitutions[sim.substitutions.mutationType == m1]);	catn("Number of fixed mutations with non zero selection coefficient: " + N_m1_fixed);	N_m0_fixed = size(sim.substitutions[sim.substitutions.mutationType == m0]);	catn("Number of fixed mutations with zero selection coefficient: " + N_m0_fixed);	// save selection coef and origin tick	file = "../../result/sim_result/" + date + "_muts_data_s" + SEED + ".csv";	writeFile(file, "Position,SelectionCoeff,OriginTick\n"); // Write header	for (mut in muts) {	line = mut.position + 1 + "," + mut.selectionCoeff + "," + mut.originTick; // position + 1 to match position in vcf	writeFile(file, line, append=T);	}	catn("Mutation data saved to " + file);	// save vcf	if (IGC) {	vcf_path = "../../result/sim_result/" + date + "_sim_igc_s" + SEED + ".vcf";	} else {	vcf_path = "../../result/sim_result/" + date + "_sim_noigc_s" + SEED + ".vcf";	}	p1.haplosomes.outputHaplosomesToVCF(vcf_path);	catn("VCF saved to " + vcf_path); } 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions