Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container to symbolize crashpad crashes #778

Merged
merged 7 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ services:
depends_on:
- base

crashpad-symbolize:
build:
args:
- GITHUB_TAG=${GITHUB_TAG:-24.lts.30}
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved
- ARCHITECTURE=${ARCHITECTURE:-arm64}
- SB_API_VERSION=${SB_API_VERSION:-15}
- CONFIG=${CONFIG:-qa}
context: ./docker/crashpad_symbolize
dockerfile: Dockerfile
image: crashpad-symbolize
volumes:
- ${MINIDUMP_PATH}:/root/minidump_directory/minidump.dmp
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved
depends_on:
- base

#### Cobalt build containers
base:
build:
Expand Down
56 changes: 56 additions & 0 deletions docker/crashpad_symbolize/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM cobalt-base

RUN apt update -qqy \
&& apt install -qqy --no-install-recommends jq build-essential zlib1g-dev libzstd-dev \
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved
&& /opt/clean-after-apt.sh

RUN cd /tmp \
&& git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'

ENV PATH=${PATH}:/tmp/depot_tools

RUN mkdir breakpad \
&& cd breakpad \
&& fetch breakpad \
&& cd src \
&& ./configure \
&& make

ARG GITHUB_TAG
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved
RUN curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/youtube/cobalt/releases/tags/${GITHUB_TAG} \
> /tmp/release.json

ARG ARCHITECTURE
ARG SB_API_VERSION
ARG CONFIG
ENV CONTAINS_STRING unstripped_${ARCHITECTURE}_sbversion-${SB_API_VERSION}_${CONFIG}
RUN jq -r --arg str "$CONTAINS_STRING" '.assets[] | select(.name | contains($str)) | .id' /tmp/release.json > /tmp/asset_ids.txt \
&& rm /tmp/release.json

RUN while read asset_id; do \
curl -LJO \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/youtube/cobalt/releases/assets/${asset_id}; \
done < /tmp/asset_ids.txt
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved

RUN id=$(cat /tmp/asset_ids.txt) && \
rm /tmp/asset_ids.txt && \
curl -s -L \
-H "Accept: application/octet-stream" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/youtube/cobalt/releases/assets/$id -o /tmp/libcobalt.tgz

RUN mkdir /tmp/cobalt-evergreen-snapshot/ && \
tar xzf /tmp/libcobalt.tgz -C /tmp/cobalt-evergreen-snapshot

RUN libcobalt_path=$(find /tmp/cobalt-evergreen-snapshot/ -name "libcobalt.so") \
&& breakpad/src/src/tools/linux/dump_syms/dump_syms $libcobalt_path > /tmp/libcobalt.so.sym \
&& debug_id=$(head -n1 /tmp/libcobalt.so.sym | cut -d' ' -f4) \
&& mkdir -p /tmp/symbols/libcobalt.so/$debug_id/ \
&& mv /tmp/libcobalt.so.sym /tmp/symbols/libcobalt.so/$debug_id/

CMD breakpad/src/src/processor/minidump_stackwalk /root/minidump_directory/minidump.dmp /tmp/symbols
35 changes: 30 additions & 5 deletions starboard/doc/evergreen/symbolizing_minidumps.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,41 @@ debugging, as these minidumps have the information for the dynamic
`libcobalt.so` module correctly mapped, which a out-of-the-box dumper could not
manage.

## Obtaining the Tools to Symbolize Minidumps
## Symbolizing with the Provided Docker Container (Recommended)

We provide a docker container at `docker/crashpad_symbolize/Dockerfile` with a
corresponding docker-compose service, `crashpad-symbolize`, with which you can
symbolize your minidumps.

Build and run the container with:

```
MINIDUMP_PATH=/path/to/minidump_file.dmp docker-compose up --build crashpad-symbolize
```

Where `MINIDUMP_PATH` is the path to your minidump file. The service will also
pick up environment values for `GITHUB_TAG`, `ARCHITECTURE`, `SB_API_VERSION`,
and `CONFIG`, so ensure these are correct.

* `GITHUB_TAG`: A Cobalt version with an associated release, i.e. 25.lts.10
* `ARCHITECTURE`: One of `x64`, `x86`, `arm64`, `arm-hardfp`, or `arm-softfp`
* `SB_API_VERSION`: The Starboard version, i.e. `16`
* `CONFIG`: One of `release` or `qa`

## Symbolizing Locally

If you wish, you can download all the necessary tools to locally symbolize
minidumps. This is more work than doing it with the docker container.

### Obtaining the Tools to Symbolize Minidumps

Tools for symbolizing these dumps are available through
[Breakpad](https://chromium.googlesource.com/breakpad/breakpad/). Breakpad is
an open source crash reporting library that we use to obtain symbol files
(`.sym`) from unstripped binaries, and to process the symbol files with the
minidumps to produce human-readable stacktraces.


### Building Breakpad
#### Building Breakpad

[Breakpad](https://chromium.googlesource.com/breakpad/breakpad/) provides
instructions for building these tools yourself. The
Expand Down Expand Up @@ -51,7 +76,7 @@ building on Linux it will also build the `dump_syms` tool
depot_tools from your `$PATH` environment variable, as it can conflict with
Cobalt's depot_tools.

## Symbolizing Minidumps
### Symbolizing Minidumps

Now that you have all the tools you need, we can symbolize the dumps. To be
able to symbolize Cobalt using Evergreen, you need to be get the unstripped
Expand Down Expand Up @@ -97,7 +122,7 @@ $ /path/to/minidump_stackwalk /path/to/your/minidump.dmp symbols/
`minidump_stackwalk` produces verbose output on stderr, and the stacktrace on
stdout, so you may want to redirect stderr.

### Addendum: Adding Other Symbols
#### Addendum: Adding Other Symbols

We can use the process above to add symbols for any library or executable you
use, not just `libcobalt.so`. To do this, all you have to do is run the
Expand Down
Loading