Stack Trace Art
Stack Trace Art is a kind of secret drawing hidden in pieces within a program, waiting to be revealed at the right moment when invoked as an error. Igor Rončević, a Croatian programmer, discovered that you can cause an error, which as it flows through the stack, pieces together ASCII art to be revealed in the stack trace. He has not only put together a series of these, but created a tool to allow others to exploit this idea.
The stack trace is a textual representation of the call stack; the flow of subroutines calling other subroutines at any moment in a running program. Usually the stack trace is seen by programmers debugging a piece of code in their development environment, or in an error log when something has gone wrong. They are lists of methods and line numbers and not terribly interesting to look at unless you're invested in the program they belong to. Unless you're viewing ones thrown by Rončević, which are ribbons, cats, or ASCII graffiti lettering.
It's a simple idea, but one that is not so easily carried out. The error itself is nothing special: a simple C# exception. The magic happens in the class throwing the exception, which has a set of methods the error flows through: one for each line of the drawing, with the ones closer to the error further up the image and so deeper in the chain. If the image were completely filled with visible characters, this would not be hard to do: we could have a series of function names with variations of aaaaaaaaaaaaaaaaa. However, that's not enough to build the cat image above: we would need to find a way to represent spaces. Rončević's solution was to find a Unicode space that C# would not recognize as a space but something else (this is very much a Microsoft-oriented project). This symbol is the Hangul Filler character, as he explains in his post His Majesty, Hangul the Filler, his ode to the symbol that makes it all possible. Hangul Filler is a control character used in representing less common Korean characters. Starting a sequence with Hangul Filler marks the following characters as intended to be combined into a single character made up of those components, as opposed to individual letters. However, as modern Unicode offers all the combinations, even of archaic signs, of these symbols, the Filler code is now essentially a legacy symbol.
The green and blue above are the name of a method, part of the call chain
Read more...






