LWN.net Logo

Displaying QR codes for kernel crashes

By Jake Edge
June 27, 2012

A proposal from Cong Wang to discuss the various mechanisms to store the kernel's "dying breath" spawned a rather large thread on the ksummit-2012-discuss mailing list. While things like pstore were set up specifically to provide a means to store kernel crash information, that doesn't necessarily make it easy for users to access and report kernel crashes. That led to suggestions and discussion of better ways for users to get the information out of their crashed systems—including using QR codes to facilitate the process.

Most regular users do not have a serial console set up to record crash information on a separate machine. So the kernel backtrace that appears after a crash is just written to the console, which means that much of it will have scrolled off the screen. Even the data that is there is hard to extract, with some folks trying to type the information in, which is tedious, not to mention error-prone. A QR code that encoded the relevant data could certainly help there.

Konrad Rzeszutek Wilk was the first to broach the QR code idea, though he said it did not originate with him. It turns out that H. Peter Anvin and Dirk Hohndel have been "messing with" the idea, but Will Deacon and Marc Zyngier actually showed something along those lines at the recent Linaro Connect in Hong Kong. Deacon was hesitant to call it a prototype, but said that there was some work done on encoding a kernel crash backtrace as a QR code. There were two problems with their approach:

  1. Even without any error correction, the QR code started to get pretty large (and unreadable) after more than a few lines of backtrace. This should be fairly easy to fix by encoding the data in a more sensible manner rather than just verbatim (especially since a backtrace is a well-structured log). Maybe you could even gzip the whole thing after that too (then sell an android app to gunzip it :p)
  2. Displaying the QR code on a panic could be problematic. We tried using the ASCII option of libqrencode but we couldn't find any phone that would read the result. So we need a way to get to the framebuffer once we've sawn our head off (maybe this is easier with x86 and VGA modes?).

One of the original motivations for kernel modesetting (KMS) was to get readable oops information to the screen. Using KMS to display a fairly simple QR code graphic instead should be workable, rather than creating an ASCII version as Deacon describes. Matthew Garrett noted that it should be fairly straightforward at least for hardware that has KMS support:

KMS already has atomic modeswitch support for showing panics. We'd just need to ensure that there's an unaccelerated path for dumping contents directly to the framebuffer. If you don't have KMS then you don't get to play with modern useful functionality.

There is some disagreement about where the decoding of any QR code should take place. Garrett believes that existing QR apps in phones should be used, while others are not convinced they can be coerced into being flexible enough to deal with the large QR codes that might result from a kernel backtrace. Garrett has also done some work on the problem and described his approach:

Basic design was as follows: Take the backtrace, compress it, encode in an alphanumeric QR code including an http:// prefix, submit to http://kbu.gs/blah automatically when user takes a picture

Anvin would rather see some kind of web application that accepts a photo of the QR code and decodes it on the server. For one thing, having one (working) decoding code base is desirable: "I can tell you just how bad a lot of the QR decoder software running on smartphones are -- because I have tried them." In addition, though, a web application would also have the photo itself, so even if it didn't decode because of picture quality or other reasons, those photos could be used to improve the quality of the decoder.

But that implies that a user would need to download an app to their phone or use some web application as suggested by John Hawley. Garrett was not in favor of either solution, noting that requiring an app makes its harder for users, while a web application doesn't really make it any better:

And now your workflow is "Take picture, move to browser, upload, wait to see if it decodes, back to camera, back to browser", etc. I know we're expected to be bad at UX here, but come on.

Given that many users already use photos to report crashes—taking a picture of the screen with the last part of the backtrace—the QR code mechanism, even if a bit cumbersome, might be able to provide the full backtrace. But, as Dave Jones suggested, just having scrollback available on the console after a crash would make much of the problem disappear: "What would be a thousand times more useful would be having working scrollback when we panic, like we had circa 2.2".

Users could then take a photo, scroll back a ways, take another, and so on. In the thread, there was widespread agreement that console scrollback would be desirable. But it turns out that the advent of USB keyboards caused the loss of that feature. Doing USB handling inside the panic code would be messy, so bringing that feature back is difficult. Other ideas were mentioned, like providing enough of the USB stack to write the crash information to a USB stick as Anvin suggests, or to "auto-scroll" the console output after a crash without requiring keyboard input as proposed by Paul Gortmaker.

Making it easier for users to report crashes with useful information was one branch of the discussion, but the folks who work on the embedded side are looking for more developer-oriented solutions as well. Tony Luck outlined the pstore back-ends that are currently available to store crash and other information in various places (ERST, EFI variables, RAM) that are accessible after a reboot. Wang, Tim Bird, Jason Wessel, and others are interested in discussing that piece of the puzzle.

While QR codes may seem like something of gimmick, they can compress a fair amount of data into a form that can be digested elsewhere. Getting useful information out of an unresponsive, crashed Linux system is fairly difficult at this point, so finding better ways to do so would be good. Should the program committee decide to add this topic, a lively discussion seems likely. If not, though, enough people are looking into the idea that something will emerge sooner or later.


(Log in to post comments)

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 3:49 UTC (Thu) by jcm (subscriber, #18262) [Link]

Hey! I suggested the idea at Linaro Connect :)

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 5:11 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

My qr_panic branch seems to date to last June, but I'd got the idea from someone else before then. I don't think it's terribly novel.

Displaying QR codes for kernel crashes

Posted Jul 12, 2012 8:47 UTC (Thu) by tf (subscriber, #85123) [Link]

Definitely not a novel idea; I recall Dirk Hondel suggesting using QR along these lines quite a while back, if my memory does not mislead me, sometime in late 2008 or early 2009.

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 10:15 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

You should have patented it and then sued $EVERYONE for $ONETRILLION USD :)

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 4:42 UTC (Thu) by joern (subscriber, #22392) [Link]

> Other ideas were mentioned, like providing enough of the USB stack to write the crash information to a USB stick as Anvin suggests

I suppose I should resend blockconsole. It has proven to catch the crash information, along with the entire kernel log, on a usb stick. It is actually surprising how robust this is, in spite of the large amount of code it depends upon.

Displaying QR codes for kernel crashes

Posted Jun 30, 2012 14:59 UTC (Sat) by mb (subscriber, #50428) [Link]

Am I the only one feeling nervous about using the block and fs subsystems on a fried kernel?

Displaying QR codes for kernel crashes

Posted Jul 1, 2012 2:28 UTC (Sun) by joern (subscriber, #22392) [Link]

> Am I the only one feeling nervous about using the block and fs subsystems on a fried kernel?

Only block, no filesystem. And so far it has had a perfect track record in our environment. A rather nice surprise, as you definitely were not the only one. ;)

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 20:54 UTC (Thu) by bjencks (subscriber, #80303) [Link]

I thought kdump was the modern solution for getting crash information. Maybe we should be encouraging distributions to make a simple "save details to disk" initrd and loading it into the kdump area by default?

Displaying QR codes for kernel crashes

Posted Jun 28, 2012 21:43 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

kdump means sacrificing ~128MB of RAM at all times in order to have somewhere to put the kdump kernel, and reliability on consumer hardware is less than stellar. It's a hard problem.

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 15:03 UTC (Mon) by bokr (subscriber, #58369) [Link]

kdump means sacrificing ~128MB of RAM at all times in order to have somewhere to put the kdump kernel, and reliability on consumer hardware is less than stellar. It's a hard problem.

How about keeping a static piece of code in the kernel that can be executed in real mode to use BIOS to reset display to 25x80 (or whatever it was) and just loop circularly over pages of dump info, outputting it in the most primitive way, with just hit-any-key as page advance? IWT this shouldn't take up more than a few KB, never mind MB.

Last gasp would be to transfer to this code.

Maybe you could use box characters to generate QR codes, 3 per screen, at 25x25 or 21x21, but that would be more code.

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 15:10 UTC (Mon) by mjg59 (subscriber, #23239) [Link]

"Hit any key" won't work via BIOS if you've got a USB keyboard, and as we head to UEFI you don't have BIOS either.

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 15:20 UTC (Mon) by apoelstra (subscriber, #75205) [Link]

Drop into real mode and use INT 10. ;)

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 15:27 UTC (Mon) by mjg59 (subscriber, #23239) [Link]

The thing about not having BIOS is that you don't have any video BIOS either :)

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 21:03 UTC (Mon) by rvfh (subscriber, #31018) [Link]

I know you're the expert here, but my USB keyboard works in my BIOS... What am I missing here?

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 21:19 UTC (Mon) by mjg59 (subscriber, #23239) [Link]

Not once the OS has taken over. It's a one-way transition.

Displaying QR codes for kernel crashes

Posted Jul 2, 2012 21:48 UTC (Mon) by apoelstra (subscriber, #75205) [Link]

Once you step out of "real mode" (i.e., 16-bit DOS mode) into "protected mode" (32-bit or 64-bit, multiple memory permission rings, all that jazz), you no longer have access to the BIOS or its interrupts, so you can't ask it for help with peripherals anymore.

Before then, the BIOS will give you keyboard access, tell you what drives are installed and what size they are, let you write to the screen, all sorts of wonderful stuff. For example, you can write "Hello world!" in assembler for an x86 PC, using only a couple dozen opcodes, which is very exciting when you're first learning about such a low level.

If UEFI really means the loss of all that, it makes me kinda sad.

Paged output, repeatedly

Posted Jun 28, 2012 23:55 UTC (Thu) by mlawren (subscriber, #10136) [Link]

Why output panic information all at once and then stop? Surely if the display size is known the info could be formatted into pages with a header ("panic page 1 of 13") and looped forever, with some suitable pause between each page.

Displaying QR codes for kernel crashes

Posted Jun 29, 2012 5:08 UTC (Fri) by naptastic (subscriber, #60139) [Link]

Maybe some other kind of 2-dimensional barcode that's easier to format for an 80x25 text console would be better? Or would that be adding a 15th competing standard?

Displaying QR codes for kernel crashes

Posted Jul 1, 2012 2:47 UTC (Sun) by pabs (subscriber, #43278) [Link]

Are the developers of Linux actually interested in receiving reports of crashes and oops? If so, you could get more reports by bringing back kerneloops.org than by QR codes.

QR codes for Haiku kernel crashes

Posted Jul 5, 2012 7:34 UTC (Thu) by kragil (guest, #34373) [Link]

http://www.osnews.com/comments/26140

Haiku will do it soon, maybe just asking them how they like it would make sense.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds