Segmentation fault in Linux server

30 views
Skip to first unread message

Luis

unread,
Jul 9, 2025, 11:11:22 PMJul 9
to slim-discuss
Hi,

I’m trying to run SLiM on my Linux server, but I encountered a “Segmentation fault (core dumped)” error. The code runs fine on my Mac, both in SLiMgui and via the command line, so I don’t think it’s a memory issue — SLiMgui reports that it uses only 36MB.

May I ask if there’s anything I need to configure in order to run SLiM on a Linux server?I’ve attached the error message and my code below. Thanks in advance.

Best,
Liaoyi

---

❯ slim -d IGC=T -d GEN=3000 -d N=15000 -d SEED=1 sim_igc.slim
// Initial random seed:
7102028955877952756

// 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 <start>:
1

Using IGC
Segmentation fault (core dumped)

---

initialize() {

if (exists("slimgui")) {
defineConstant("IGC_RATE", 2.5e-7);
defineConstant("alpha", 1.3e-8/3);
defineConstant("SD_len", 10000);
defineConstant("N", 15000);
defineConstant("IGC", T);
defineConstant("GEN", 300000);
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", 15000);
if (!exists("IGC")) defineConstant("IGC", T);
if (!exists("GEN")) defineConstant("GEN", 300000);
if (!exists("SEED")) defineConstant("SEED", 1);

initializeSLiMModelType("WF");
initializeSLiMOptions(nucleotideBased=T);

setSeed(SEED);

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);
}

Ben Haller

unread,
Jul 10, 2025, 9:27:20 AMJul 10
to Luis, slim-discuss
Hi Liaoyi,

There's no special configuration for Linux, no.

It's hard to guess what the problem might be.  You need to try to extract a backtrace and other debugging information from the core dump that was produced by the crash.  The procedure for doing so will depend on the Linux platform and version that you're using, so you should use Google to try to track down how to do it.  Without that, the reason for the crash is just a complete mystery.

The first possibility to check is that the segfault might be due to a bug in SLiM itself.  In this case, the backtrace from the core dump would certainly be helpful.  To narrow this down, it would also be helpful to construct a minimal reproducible example – i.e., a SLiM model that reproduces the problem (on your Linux server, at least) without the very long runtime of the model you posted.  Try shortening the model's runtime and simplifying the model design, cutting out chunks of it as much as you can while still having the crash occur.  If it only happens sometimes, not every run, try to find a random number seed for the run that reproduces the bug reliably.  If you get a minimal reproducible example like that, please make a new issue in GitHub against the SLiM repository and post your minimal example there, with previous information from this thread.  But the backtrace would still be essential, since – as far as we know – this bug only occurs on your Linux box, nowhere else.  I can try to reproduce the problem on my end, but I'm on macOS, and the runtime of the model is too long right now anyway; I can't tie up my laptop running a huge model like this.

The other possibility is that there might be some kind of version incompatibility or inconsistency deeper down in the software stack; in other words, SLiM might be fine, but there might be a deeper problem in the configuration of the machine.  You can try building SLiM directly from sources, if you installed it using an installer; instructions for building from sources are given in chapter 2 of the SLiM manual.  A backtrace, etc., from the core dump might help to diagnose this situation too (or might not).  If you have a system administrator for this server who can help you with this problem, that would be best; such problems can be quite hard to figure out and fix.  If you are the administrator of the system, then the best I can suggest is to wipe the machine and reinstall all installed packages from scratch, using recent versions of the operating system and packages.

I'd look into the first possibility first; you don't want to waste time wiping and installing everything if the bug is in SLiM.  Good luck!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Luis wrote on 7/10/25 4:11 AM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/5a0baef1-b8ae-430e-81e3-f9a8a44eb43bn%40googlegroups.com.

Message has been deleted

Luis

unread,
Jul 10, 2025, 11:46:59 PMJul 10
to slim-discuss
Hi Ben,

Thanks for your prompt reply!

I tried building SLiM directly from source, but I still encountered the same segmentation fault error. However, it seems I’ve identified the problematic line:

`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);`

After removing this line, the error no longer occurs on my Linux server. Interestingly, the code runs fine on my Mac even with this line included, so I’m unsure whether the issue lies in the code itself or something else. I’ve attached the backtrace and a minimal reproducible example below.

Thank you!
Liaoyi
---

Backtrace:

(gdb) bt
#0  0x0000153781316891 in free () from /usr/lib64/libc.so.6
#1  0x00000000008c2dba in __gnu_cxx::new_allocator<char>::deallocate (__p=<optimized out>, this=0x243c140) at /usr/include/c++/8/ext/new_allocator.h:116
#2  std::allocator_traits<std::allocator<char> >::deallocate (__n=<optimized out>, __p=<optimized out>, __a=...) at /usr/include/c++/8/bits/alloc_traits.h:462
#3  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (__size=<optimized out>, this=0x243c140)
    at /usr/include/c++/8/bits/basic_string.h:230
#4  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (this=0x243c140) at /usr/include/c++/8/bits/basic_string.h:225
#5  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x243c140, __in_chrg=<optimized out>)
    at /usr/include/c++/8/bits/basic_string.h:661
#6  std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (__pointer=0x243c140) at /usr/include/c++/8/bits/stl_construct.h:98
#7  std::_Destroy_aux<false>::__destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (__last=<optimized out>, __first=0x243c140)
    at /usr/include/c++/8/bits/stl_construct.h:108
#8  std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (__last=<optimized out>, __first=<optimized out>)
    at /usr/include/c++/8/bits/stl_construct.h:137
#9  std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (__last=0x25bdd80, __first=<optimized out>) at /usr/include/c++/8/bits/stl_construct.h:206
#10 std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~vector (this=0x1cf6ff8, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/stl_vector.h:567
#11 EidosValue_String::~EidosValue_String (this=0x1cf6fe0, __in_chrg=<optimized out>) 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<EidosValue>::~Eidos_intrusive_ptr (this=<optimized out>, __in_chrg=<optimized out>)
    at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_intrusive_ptr.h:115
#14 Eidos_intrusive_ptr<EidosValue>::reset (this=0x1e67020) at /work/09059/xliaoyi/ls6/software/SLiM/eidos/eidos_intrusive_ptr.h:153
#15 EidosSymbolTable::~EidosSymbolTable (this=0x7ffe56603fd0, __in_chrg=<optimized out>) 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=<optimized out>, argv=<optimized out>) 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 <start>:
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 reproduce 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();

Ben Haller

unread,
Jul 11, 2025, 3:16:22 AMJul 11
to Luis, slim-discuss
Hi Luis!  Let's take this off-list.  It does sound like it is probably a SLiM bug of some kind, although it's unusual that it manifests on only one platform.  Please open a GitHub issue providing the information you've given, and we can communicate further there.  Awesome that you got a backtrace, that is quite helpful.  What is most needed now is a minimal reproducible example; for example, does this crash still happen if you cut 99% of the ticks out of the model you gave?  Does it require a specific random number seed?  Please provide that information in the GitHub issue.  With an example that I can reasonably run on my end, I can probably track this down and get a fix pushed to GitHub, and then you can build from the current GitHub head and get the fix, which should get you up and running.  :->


Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Luis wrote on 7/11/25 4:46 AM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages