Core dumps now supported on CircleCI 2.0

For projects using CircleCI 2.0, you can now get core dumps and push them as artifacts for inspection and debugging.

A contrived example

If you want to skip ahead to the configuration, go ahead.

In order to demonstrate this feature, we’ll create with a tiny C program that simply does an abort(3) to crash the program.

Starting with the Makefile:

	gcc -o dump main.c

Now let’s create our circle.yml.

#include <stdlib.h>

int main(int argc, char **argv) {

Now if we run make and ./dump on the generated program, we should see Aborted (core dumped)!


Let’s take a look at the full circle.yml for compiling this program, and collecting the core dumps as artifacts.

version: 2.0

      - image: gcc:latest
    working_directory: ~/work
      - checkout
      - run: make
      - run: |
          ulimit -c unlimited
      - run:
          command: |
            mkdir -p /tmp/core_dumps
            cp core.* /tmp/core_dumps
          when: on_fail
      - store_artifacts:
          path: /tmp/core_dumps

The important parts here are ulimit -c unlimited which tells the operating system to remove the file size limit on core dump files.

With the limit removed, anytime a program crashes a dump file will be created in the current working directory. The name it will be given, as specified in /proc/sys/kernel/core_pattern will be core.%p.%E where %p is the process id and %E is the pathname of the executable.

Lastly, we copy the dump files to /tmp/core_dumps and send them off to the artifacts services with store_artifacts.

If we run a build, you should see the core dump file under the “Artifacts” tab of the build summary!

We welcome your feedback as we continue to develop and improve CircleCI 2.0: