@@ -165,6 +165,24 @@ functions:
165165 set -o xtrace
166166 ${PREPARE_SHELL}
167167 find $MONGO_ORCHESTRATION_HOME -name \*.log | xargs tar czf mongodb-logs.tar.gz
168+ - command : archive.targz_pack
169+ params :
170+ target : " mongo-coredumps.tgz"
171+ source_dir : " ./"
172+ include :
173+ - " ./**.core"
174+ - " ./**.mdmp" # Windows: minidumps
175+ - command : s3.put
176+ params :
177+ aws_key : ${aws_key}
178+ aws_secret : ${aws_secret}
179+ local_file : mongo-coredumps.tgz
180+ remote_file : ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/coredumps/${task_id}-${execution}-mongodb-coredumps.tar.gz
181+ bucket : mciuploads
182+ permissions : public-read
183+ content_type : ${content_type|application/gzip}
184+ display_name : Core Dumps - Execution
185+ optional : true
168186 - command : s3.put
169187 params :
170188 aws_key : ${aws_key}
@@ -236,6 +254,34 @@ functions:
236254 params :
237255 script : |
238256 set -o xtrace
257+
258+ # Enable core dumps if enabled on the machine
259+ # Copied from https://github.com/mongodb/mongo/blob/master/etc/evergreen.yml
260+ if [ -f /proc/self/coredump_filter ]; then
261+ # Set the shell process (and its children processes) to dump ELF headers (bit 4),
262+ # anonymous shared mappings (bit 1), and anonymous private mappings (bit 0).
263+ echo 0x13 > /proc/self/coredump_filter
264+
265+ if [ -f /sbin/sysctl ]; then
266+ # Check that the core pattern is set explicitly on our distro image instead
267+ # of being the OS's default value. This ensures that coredump names are consistent
268+ # across distros and can be picked up by Evergreen.
269+ core_pattern=$(/sbin/sysctl -n "kernel.core_pattern")
270+ if [ "$core_pattern" = "dump_%e.%p.core" ]; then
271+ echo "Enabling coredumps"
272+ ulimit -c unlimited
273+ fi
274+ fi
275+ fi
276+
277+ if [ $(uname -s) == "Darwin" ]; then
278+ core_pattern_mac=$(/usr/sbin/sysctl -n "kern.corefile")
279+ if [ "$core_pattern_mac" = "dump_%N.%P.core" ]; then
280+ echo "Enabling coredumps"
281+ ulimit -c unlimited
282+ fi
283+ fi
284+
239285 ${PREPARE_SHELL}
240286 MONGODB_VERSION=${VERSION} \
241287 TOPOLOGY=${TOPOLOGY} \
0 commit comments