{"componentChunkName":"component---src-components-mark-down-block-js","path":"/docs/crash-analysis/","result":{"data":{"markdownRemark":{"html":"<h2 id=\"analyzing-application-crashes\" style=\"position:relative;\"><a href=\"#analyzing-application-crashes\" aria-label=\"analyzing application crashes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Analyzing Application Crashes</h2>\n<p>When an application crashes, you can use AppScope together with <a href=\"https://ebpf.io/what-is-ebpf/\">eBPF</a> to generate useful files and send those files to a network destination, before the environment is torn down.</p>\n<p>In the walkthrough that follows, we'll run Nginx in a Docker container, force Nginx to crash, and send crash data – backtrace, core dump, and snapshot files – through Cribl.Cloud to Amazon S3.</p>\n<p>If you prefer, you can easily adapt the procedure to analyze a crash of any process (not just Nginx); run on the host rather than a container; or, route the crash data to any network destination (not just Cribl.Cloud). You can even skip the network destination entirely and just view the crash files on disk.</p>\n<h3 id=\"prerequisites\" style=\"position:relative;\"><a href=\"#prerequisites\" aria-label=\"prerequisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prerequisites</h3>\n<p>You will need:</p>\n<ul>\n<li>An Amazon S3 account.</li>\n<li>A Linux host with Docker installed.</li>\n<li>A Cribl.Cloud instance – you can sign up for a free account at <a href=\"https://cribl.cloud\">https://cribl.cloud</a>.</li>\n</ul>\n<h3 id=\"setting-up-your-criblcloud-instance\" style=\"position:relative;\"><a href=\"#setting-up-your-criblcloud-instance\" aria-label=\"setting up your criblcloud instance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting Up Your Cribl.Cloud Instance</h3>\n<p>In Cribl.Cloud, start by creating an Amazon S3 Destination:</p>\n<ol>\n<li>Click <strong>Manage Stream</strong>.</li>\n<li>Under <strong>Worker Groups</strong>, click <code>default</code>.</li>\n<li>Click <strong>Data</strong> > <strong>Destinations</strong> and choose the Amazon S3 Destination.</li>\n<li>Click <strong>Add Destination</strong> and configure the Destination with your S3 credentials and preferences. </li>\n<li>Click <strong>Save</strong>.</li>\n</ol>\n<p>Next, configure the built-in TCP Source:</p>\n<ol>\n<li>Click <strong>Data</strong> > <strong>Sources</strong> and choose the TCP Source.</li>\n<li>Click the built-in <code>in_tcp</code> Source, enable it, and configure it with address <code>0.0.0.0</code> and port <code>10060</code>.</li>\n<li>Click <strong>Connected Destinations</strong> and choose <strong>QuickConnect</strong>. Select your S3 Destination. </li>\n<li>Click <strong>Save</strong>.</li>\n<li>Click <strong>Commit and Deploy</strong>.</li>\n</ol>\n<p>You now have a Cribl.Cloud Worker listening for TCP data, and configured to send it on to S3.</p>\n<h3 id=\"setting-up-appscope-and-ebpf\" style=\"position:relative;\"><a href=\"#setting-up-appscope-and-ebpf\" aria-label=\"setting up appscope and ebpf permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting Up AppScope and eBPF</h3>\n<p>The <code>scope-ebpf</code> and AppScope projects are separate and independent, and they operate under different licenses – for that reason, each has its own repo.</p>\n<p>Download the AppScope binary:</p>\n<pre><code>cd ~/Downloads  \ncurl -Lo scope https://cdn.cribl.io/dl/scope/1.4.1/linux/$(uname -m)/scope\ncurl -Ls https://cdn.cribl.io/dl/scope/1.4.1/linux/$(uname -m)/scope.md5 | md5sum -c \nchmod +x scope\n</code></pre>\n<p>Download and build the <code>scope-ebpf</code> binary:</p>\n<pre><code>git clone git@github.com:criblio/scope-ebpf.git\ncd scope-ebpf\nmake all\n</code></pre>\n<p>Deploy the eBPF module to listen for crashing applications:</p>\n<pre><code>sudo ~/Downloads/scope-ebpf/bin/scope-ebpf\n</code></pre>\n<p>Leave this shell running and open another terminal or tab.</p>\n<p>Deploy the AppScope daemon, to receive messages from eBPF and send crash files to a network destination:</p>\n<pre><code>sudo ~/Downloads/scope daemon --filedest tcp://&#x3C;path-to-cribl-cloud-tcp>:10060\n</code></pre>\n<p>Once you start the daemon, the <code>scope-ebpf</code> binary will exit in the other terminal. That's normal.</p>\n<p>At this point, preparation is complete:</p>\n<ul>\n<li>The eBPF kernel module should be loaded, listening for application crash signals. </li>\n<li>The AppScope Daemon should be running, waiting for the eBPF module to tell it that an application has crashed. </li>\n<li>Once eBPF notifies AppScope of a crash, AppScope will look for crash files and send them on to the configured network destination.</li>\n</ul>\n<h3 id=\"making-an-application-crash\" style=\"position:relative;\"><a href=\"#making-an-application-crash\" aria-label=\"making an application crash permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Making an Application Crash</h3>\n<p>Start a daemonized Nginx container:</p>\n<pre><code>docker run --rm -d nginx\n</code></pre>\n<p>Attach AppScope to the containerized Nginx process, and enable backtrace and core dump on crash:</p>\n<pre><code>sudo ~/Downloads/scope attach --backtrace --coredump nginx\n</code></pre>\n<p>This command shows the Nginx process with its child processes, in a list. Note the PID of the parent Nginx process.</p>\n<p>(Alternatively, you could have used the <code>scope run</code> <a href=\"cli-reference#run\">command</a> or the <code>scope rules</code> <a href=\"cli-reference#rules\">command</a> to tell AppScope to load itself into an application when it starts.)</p>\n<p>Force a crash of Nginx by sending the process a <code>BUS</code> error signal:</p>\n<pre><code>sudo kill -s SIGBUS &#x3C;PID_of_nginx>\n</code></pre>\n<p>AppScope will respond to any of the usual signals of a crashing process: <code>SIGBUS</code>, <code>SIGINT</code>, <code>SIGSEGV</code>, or <code>SIGFPE</code>.</p>\n<p>Now look in your S3 bucket – you should see four files: <code>info</code>, <code>backtrace</code>, <code>snapshot</code>, and <code>cfg</code>. The same files, plus the core dump, should also be in <code>/tmp/appscope/&#x3C;PID_of_nginx>/</code>.</p>\n<h3 id=\"investigating-the-crash\" style=\"position:relative;\"><a href=\"#investigating-the-crash\" aria-label=\"investigating the crash permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating the Crash</h3>\n<p>Here are a few hints about the meaningful insights that the crash files provide.</p>\n<p>The backtrace file contains the application stack trace at the time of the crash:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/740862154e6e84dc8e0ab131cc46b7d2/58fee/AppScope-Backtrace-screenshot.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 47.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABS0lEQVQoz4WSWZOCMBCE8QDx5pQAQkBcBfX//73e6bHYN5aHrpmqJJ1vDscYgzhORBE8z0MQBPB9X7Xf77HdbnE4HDVGUST5AafTCbvdTuPxyDNf881mA6euKlRVjTw3WK/XWK1W8OVgzB3H0XyxWGg+q6axePY9+v6JtmmQCfHz8YC1FtfrFUWRo+s6nM9npSPZv4Z8cLvdVKQNw0hpjclxuaRqoqXI5eVyOU/aidHr9cYw9GpqbSOkFlVdK1mSJNrDOI7huu5fGyaVS4lN26IVscQgCLXcsiyF8CK0uUbPc3VII+2kSPV6v6WHvZh+e0jq+/1HjYzJdOIjHTeBQ5o0tFJaJb0jEVfou0Yx0jRVjSvEXtKMQ2GcNKzF8PP5COGAQSi5h1mWoZAPyrJQU34QhqHG2bXhA5qWRaGDIAkHQWP2cyRiydSc4S+r7OZpaAjjQwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AppScope crash backtrace\"\n        title=\"AppScope crash backtrace\"\n        src=\"/static/740862154e6e84dc8e0ab131cc46b7d2/5a190/AppScope-Backtrace-screenshot.png\"\n        srcset=\"/static/740862154e6e84dc8e0ab131cc46b7d2/772e8/AppScope-Backtrace-screenshot.png 200w,\n/static/740862154e6e84dc8e0ab131cc46b7d2/e17e5/AppScope-Backtrace-screenshot.png 400w,\n/static/740862154e6e84dc8e0ab131cc46b7d2/5a190/AppScope-Backtrace-screenshot.png 800w,\n/static/740862154e6e84dc8e0ab131cc46b7d2/58fee/AppScope-Backtrace-screenshot.png 1051w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p>The snapshot file contains properties of the process:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/0bc21c6da17fc3507ffc50c3a6836de6/e996b/AppScope-Snapshot-screenshot.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 45.49999999999999%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA3klEQVQoz52S2YqFMBBEBeOCGrfEuA6oiOD/f2DdVHPnYWA2fShCAn2oqk5QFAWsNUjTFH3fo65rdF0nJ1WWpby3bYvK360xUEohCILvxaF1XbEsH9C6gDEWeZb9PPCXMj88TRP2ffcwg2EYxFme5wjD8D4wSRLEcSwxGJsVKBU+g1FN0/i4i4Cc66UvrbU45NttcOs7u64L53niOA5ZwjiOIuecaHzX8C9gVdUYvKt5nrFtm7jiRumSNURRBNby62a/Ais4/00IIuRxd5+yHsYN0yHdMJpznWyb8e8CX6uYwwqdXSB+AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AppScope crash snapshot\"\n        title=\"AppScope crash snapshot\"\n        src=\"/static/0bc21c6da17fc3507ffc50c3a6836de6/5a190/AppScope-Snapshot-screenshot.png\"\n        srcset=\"/static/0bc21c6da17fc3507ffc50c3a6836de6/772e8/AppScope-Snapshot-screenshot.png 200w,\n/static/0bc21c6da17fc3507ffc50c3a6836de6/e17e5/AppScope-Snapshot-screenshot.png 400w,\n/static/0bc21c6da17fc3507ffc50c3a6836de6/5a190/AppScope-Snapshot-screenshot.png 800w,\n/static/0bc21c6da17fc3507ffc50c3a6836de6/e996b/AppScope-Snapshot-screenshot.png 1050w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p>The core dump (not shown here) contains a binary snapshot of the application at the time of the crash, for inspection with a debugger like gdb. By default, the daemon does not send this over the network since it's not usually useful outside of its origin environment. The <a href=\"https://man7.org/linux/man-pages/man5/core.5.html\">man page</a> on core dumps can help you explore this data.</p>\n<p>If this topic is of interest to you, and/or if you'd like some help getting the procedure to work, please get in touch – there are a <a href=\"https://appscope.dev/docs/community/\">variety</a> of ways to do that.</p>","frontmatter":{"title":"Analyzing Application Crashes"}}},"pageContext":{"slug":"/crash-analysis/","id":"5857d3f7-b3d8-50c6-b2c2-cb6fc7701ed0"}},"staticQueryHashes":["2787008656","306729481","625673991","640077088"]}