Open cerebis opened 4 years ago
I found that prctl could be used in Linux to enable clean-up of children when their parent process dies, but I later learned that this system function is not available under OSX.
Out of curiosity I took to OSX to see if I could reproduce the problem there. In testing on a non-virtual Mac with 32GB of physical memory and default swap of 11G, I found that I could not cause the allocation error even with a hash size of 2000G.
Therefore I suppose this error mode is unlikely and more a product of a tiny 4GB virtual machine.
I have made a fork of the codebase if you wish to see the small change to use prctl. Perhaps there is a means of doing this in OSX, but in my search I could not find any discussions.
Situation
When counting kmers and requesting a hash size that is larger than available memory, while using generators.
E.g. on a 4GB VM, the following will SIGABRT after attempting to allocate 8GB for the hash.
Outcome
Jellyfish will fault with a SIGABRT, however the child process tree pertaining to the generators will become orphaned and subsequently adopted by systemd.
Console error.
For a single threaded generator, this leaves behind the following proceses, where PID 1775 is systemd.
Solution
Looking at the code,
count_main.cc
sets up asigaction
for SIGTERM. Adding an identical sigaction for SIGABRT results in one of these orphans being cleaned up but not both. It looks like someone more conversant with your codebase could improve this to properly clean up thegenerator_manager
.E.g.