• Stars
    star
    3,518
  • Rank 12,636 (Top 0.3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crash your app in style (Golang)

panicparse

Parses panic stack traces, densifies and deduplicates goroutines with similar stack traces. Helps debugging crashes and deadlocks in heavily parallelized process.

PkgGoDev codecov go-recipes

panicparse helps make sense of Go crash dumps:

Screencast

Features

  • Race detector support, e.g. it can parse output produced by go test -race
  • HTML export.
  • Easy to use as an HTTP Handler middleware.
  • High performance parsing.
  • HTTP web server that serves a very tight and swell snapshot of your goroutines, much more readable than net/http/pprof.
  • >50% more compact output than original stack dump yet more readable.
  • Deduplicates redundant goroutine stacks. Useful for large server crashes.
  • Arguments as pointer IDs instead of raw pointer values.
  • Pushes stdlib-only stacks at the bottom to help focus on important code.
  • Parses the source files if available to augment the output.
  • Works on any platform supported by Go, including Windows, macOS, linux.
  • Full go module support.
  • Requires >=go1.17. Use v2.3.1 for older Go versions.

Installation

go install github.com/maruel/panicparse/v2/cmd/pp@latest

Usage

Piping a stack trace from another process

TL;DR

  • Ubuntu (bash v4 or zsh): |&
  • macOS, install bash 4+, then: |&
  • Windows or macOS with stock bash v3: 2>&1 |
  • Fish shell: &|

Longer version

pp streams its stdin to stdout as long as it doesn't detect any panic. panic() and Go's native deadlock detector print to stderr via the native print() function.

Bash v4 or zsh: |& tells the shell to redirect stderr to stdout, it's an alias for 2>&1 | (bash v4, zsh):

go test -v |&pp

Windows or macOS native bash (which is 3.2.57): They don't have this shortcut, so use the long form:

go test -v 2>&1 | pp

Fish: &| redirects stderr and stdout. It's an alias for 2>&1 | (fish piping):

go test -v &| pp

PowerShell: It has broken 2>&1 redirection. The workaround is to shell out to cmd.exe. :(

Investigate deadlock

On POSIX, use Ctrl-\ to send SIGQUIT to your process, pp will ignore the signal and will parse the stack trace.

Parsing from a file

To dump to a file then parse, pass the file path of a stack trace

go test 2> stack.txt
pp stack.txt

Tips

Disable inlining

The Go toolchain inlines functions when it can. This causes traces to be less informative. Optimization also interfere with traces. You can use the following to help diagnosing issues:

go install -gcflags '-N -l' path/to/foo
foo |& pp

or

go test -gcflags '-N -l' ./... |& pp

Run go tool compile -help to get the full list of valid values for -gcflags.

GOTRACEBACK

By default, GOTRACEBACK defaults to single, which means that a panic will only return the current goroutine trace alone. To get all goroutines trace and not just the crashing one, set the environment variable:

export GOTRACEBACK=all

or set GOTRACEBACK=all on Windows. Probably worth to put it in your .bashrc.

Updating bash on macOS

Install bash v4+ on macOS via homebrew or macports. Your future self will appreciate having done that.

If you have /usr/bin/pp installed

If you try pp for the first time and you get:

Creating tables and indexes...
Done.

and/or

/usr/bin/pp5.18: No input files specified

you may be running the Perl PAR Packager instead of panicparse.

You have two choices, either you put $GOPATH/bin at the beginning of $PATH or use long name panicparse with:

go install github.com/maruel/panicparse/v2@latest

then using panicparse instead of pp:

go test 2> panicparse

Hint: You may also use shell aliases

alias gp=panicparse
go test 2> gp

alias p=panicparse
go test 2> p

webstack in action

The webstack.SnapshotHandler http.Handler enables glancing at at a snapshot of your process trivially:

Screencast

Authors

panicparse was created with ❀️️ and passion by Marc-Antoine Ruel and friends.

More Repositories

1

pre-commit-go

Toolkit for checks on a Go project before committing via pre-commit git hook. Includes coverage. Fast.
Go
131
star
2

serve-dir

"python -m SimpleHTTPServer" but FAST
Go
64
star
3

natural

Natural sorting (natsort) in Go
Go
50
star
4

go-lepton

Serves images taken on a FLIR Lepton connected to a Raspberry Pi SPI port to over HTTP.
Go
26
star
5

dlibox

Home automation that does not depend on the internet
Go
25
star
6

subcommands

Permits a Go application to implement subcommands support similar to what is supported by the 'go' tool.
Go
22
star
7

circular

Efficient thread-safe circular byte buffer to keep in-memory logs
Go
21
star
8

temperature

Converts between color temperature in Kelvin and in RGB (Golang)
Go
19
star
9

rs

Reed-Solomon error correction code in Go
Go
16
star
10

webskel

A template to make free web site generated by Hugo, hosted on GitHub pages, using CloudFlare for HTTPS
HTML
12
star
11

market_track

Google Apps script for Google Sheets to track exchange rates, international stocks and funds
JavaScript
12
star
12

mapreduce

A simple cachable mapreduce Golang implementation
Go
12
star
13

bolide-esp8266

A automatisable 40$ wifi enabled race car πŸš—
C++
12
star
14

nin

nin: I love the sound of my build. Build system in Go.
C++
11
star
15

serve-mp4

Serves transcoded MP4's for ChromeCast and ChromeOS
Go
11
star
16

pat

Performance Analysis Toolbox for Go programs.
Go
10
star
17

hugo-tidy

Docker image to generate the fastest (minified, gzipped) web site via Hugo
Shell
8
star
18

dumbcas

Backup tool based on a simple Content Addressed Datastore
Go
7
star
19

anim1d

Idempotent 1D animation system
Go
6
star
20

interrupt

Package interrupt is a single global way to handle process interruption in Go
Go
6
star
21

interfaceGUID

Calculates a unique hash based identifier for a Go interface.
Go
6
star
22

sillybot

A simple Discord&Slack bot that runs LLM (Llama-3, Phi-3, Gemma-2, Mistral) and Stable Diffusion
Go
5
star
23

ansi256

RGB to terminal color palette function in Go
Go
5
star
24

msgbus

A simplified interface to MQTT
Go
5
star
25

bin_pub

Contains all my public scripts and configuration, under a BSD license
Shell
4
star
26

bench

A collection of low level Go and CPU benchmarks
Go
3
star
27

fastbezier

Fast bezier cubic curve evaluation over uint16 domain in Go and generator for C
Go
3
star
28

fortuna

Fortuna cryptographic random number generator in Go
Go
3
star
29

ut

Compact testing utilities to shorten Go unit tests.
Go
3
star
30

restroom

Go
2
star
31

ml

Playing with jupyterlab + with various ML libraries
Jupyter Notebook
2
star
32

ellee

Esphome Lambda Light Effect Emulator
Python
2
star
33

meetin

Enlighten your meetings.
Go
2
star
34

bambu_studio

Quickly setup Bambu Studio as a proper application in Ubuntu, with a one liner to upgrade to the latest version.
Shell
2
star
35

ircam-esp32

InfraRed camera for ESP32
C++
1
star
36

mlphoto

PhotoMaker v2 script, includes stylizing
Python
1
star
37

argent

Scripts to manage money
Python
1
star
38

covg

yet another coverage tool
Go
1
star
39

mastodon-sample

Sample repository to help setup Mastodon with docker-compose
Shell
1
star
40

git-scan

Starts a web server to answer oracle questions about the git repository [Experimental]
Go
1
star
41

http-503

Trivial AppEngine app to return an http error code on all requests.
Python
1
star
42

ffa3

FlashForge Adventurer 3 Go tooling
Go
1
star
43

resilience

Package resilience exposes an http.Handler that returns an HTTP failure randomly to improve client resiliency.
Go
1
star
44

are_you_there_hass

Chrome Extension to report desktop lock state to Home Assistant
JavaScript
1
star
45

query-github-runner

Workflow that queries the hosted GitHub windows runner configuration to help understanding the running environment
1
star
46

halloween2018

Go
1
star
47

psf

Leverage .psf fonts found on unix hosts for use in Go programs
Go
1
star
48

emperor-esp8266

Control a MWELabs Emperor 1510 chair with an ESP8266
Shell
1
star
49

git-hooks-go

Stale project; DO NOT USE.
Python
1
star
50

git_utils

Collection of small git utilities useful to me, that also happen to work on Windows (written in python)
Python
1
star