logoalt Hacker News

Groxxyesterday at 6:47 PM1 replyview on HN

I've seen more than one half-joke-half-serious chunk of code that would "encode" arbitrary info into stack traces simply by recursively calling `fn_a`, then `fn_s`, `fn_d`, and `fn_f` before continuing with the actual intended call, giving you a stack trace with (effectively) "asdf" in it.

They've also been useful more than once, e.g. you can do that to know what iteration of a loop failed. There are of course other ways to do this, but it's hard to beat "stupid, simple, and works everywhere" when normal options (e.g. logs) stop working.


Replies

0x70ddyesterday at 7:01 PM

Reminds me of https://github.com/jtolio/gls which implement a "thread local storage" in golang