Cyber Risks · Trail of Bits Blog

Panicking the right way in Go

Summary: Trail of Bits describes a Go idiom in which code panics, recovers in a deferred function, and continues, and notes that global state changes made before the panic are not undone by recover. The firm built a tool called OnEdge that re-executes the panicking function in a shadow thread so Go's race detector, enabled with the -race flag, reports the conflicting global write as a data race.

What's compelling: Trail of Bits cites blockchain software written in Go that panics on an invalid transaction and continues processing, where a partially applied transaction could cause the blockchain to fork. OnEdge is a dynamic analysis: if no input ever triggers a panic, it finds nothing, and the race detector's own limits mean some global state changes can still be missed.

Read the original at Trail of Bits Blog ↗