the history and future of core dumps in freebsd

27
Introduction Background The Past The Present The Future Conclusion The History and Future of Core Dumps in FreeBSD Sam W. Gwydir, Texas A&M University [email protected] March 25, 2017 Sam W. Gwydir, Texas A&M University [email protected] The History and Future of Core Dumps in FreeBSD

Upload: sam-gwydir

Post on 11-Apr-2017

45 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

The History and Future of Core Dumps inFreeBSD

Sam W. Gwydir, Texas A&M University [email protected]

March 25, 2017

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 2: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Who Am I?

My name is Sam GwydirI Texas A&M University - Graduating in MayI Computer Engineering/Computer Science & MathematicsI I’ve used *NIX for about 12 yearsI OpenBSD, and later FreeBSD for about 4

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 3: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Overview

I Who Am I?I Background

I What is a Coredump?I ProcedureI Tutorial

I The PastI Timelines

I The PresentI FreeBSDI IllumosI Mac OS XI Backtrace.io

I The FutureI Core Dump Extensions

I Modular Dump CodeI netdumpI minidumpszI Compressed Dump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 4: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

What is a Core Dump?

Core Dump A machine readable form of the state of a machine atsome point in time, usually after a panic(9).Useful for debugging both userspace programs and thekernel – we will focus on the kernel today.Written using various methods to various over the years

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 5: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

General Dump Procedure (4.1 BSD - FreeBSD CURRENT)

I Started by a panic(9), reboot -dI sysctl debug.kdb.panic=1I dtrace -w -n ’BEGIN{ panic();}’

I dumpsys() lands all/part of memory on swap in a particular formatI On reboot, savecore(8) writes dump to dumpdir for analysis

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 6: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

How to take a Core Dump in FreeBSD

I You are purposely panicking your machine.I Do this in a VM!

root@:~ # sysrc dumpdev="AUTO" dumpdir="/var/crash"root@:~ # mkdir /var/crash # create the dumpdirroot@:~ # chmod 700 /var/crash # fix permissionsroot@:~ # # for text dump: sysctl debug.ddb.textdump.pending=1root@:~ # sysctl debug.kdb.panic=1

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 7: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Overview

I Who Am I?I BackgroundI The Past

I TimelinesI The Present

I FreeBSDI IllumosI Mac OS XI Backtrace.io

I The FutureI Core Dump Extensions

I Modular Dump CodeI netdumpI minidumpszI Compressed Dump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 8: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

The History

I The Odyssey of doadump()I Starts at 6th Edition Research UNIX’s crash(8)I Ends at FreeBSD 12-CURRENT’s Encrypted DumpI Turn to the Appendix for a more in depth history

I Includes architecture supportI Feature changes and larger bug fixes

I For even more depth, go to the org-mode file on github.I Includes commits, mailing list emails, copious notes.

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 9: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Core Dump Output Format Time Line

Figure 1: Core Dump Types

“Well in 1979 I can remember doing a crash dump on a HarrisS/210 24 bit machine to the line printer in octal, it only took 2hours to print. . . .” - rgrimes

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 10: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

FreeBSD Core Dump Extension

Figure 2: Core Dump Extension Timeline

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 11: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Overview

I Who Am I?I BackgroundI The PastI The Present

I FreeBSDI IllumosI Mac OS XI Backtrace.io

I The FutureI Core Dump Extensions

I Modular Dump CodeI netdumpI minidumpszI Compressed Dump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 12: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

What is a Core Dump?

Two Types:

Full Dump Full contents of memory. Current procedure dates to 4.1BSD. If you need help with your PDP-11 instructions arein the appendix.

Minidump Only active kernel pages are dumped. Added By PeterWemm in FreeBSD 6.2. The default as of FreeBSD 7.0.

What is inside?

info Metadata about dump (time, panic string, hostname)core.txt System info (backtrace, ps, vmstat, netstat, fstat)vmcore core itself

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 13: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Full Dump On-Disk Format

Figure 3: Full Dump Format

I Full Dump (FreeBSD 6.0)I A classic core dump – the full contents of memory at the time of a

crashI ELF Format (a.out previous to FreeBSD 6.0)

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 14: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Minidump On-Disk Format

Figure 4: Mini Dump Format

I Minidump (FreeBSD 6.2) - Peter WemmI Contains only memory pages in use by kernelI Much smaller than the full contents of memory, modern dumps can

still be fairly largeI Custom “minidump” Format

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 15: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

What is a Text Dump?

textdump(4) “The textdump facility allows the capture of kerneldebugging information to disk in a human-readable ratherthan the machine-readable form normally used with kernelmemory dumps and minidumps.”Added by Robert Watson in FreeBSD 7.1.

What is inside?I Other files are easily added with a small patch

version.txt Kernel version stringpanic.txt Kernel panic messagemsgbuf.txt Kernel message bufferconfig.txt Kernel configurationddb.txt Captured DDB output

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 16: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Text Dump On-Disk Format

Figure 5: Text Dump Format

I Text Dump (FreeBSD 7.1) - Robert WatsonI Custom ddb scripting in lieu of a dumpI Written backwards because size is unknown a priori.I USTAR format

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 17: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Core Dumps vs Textdumps

BothI Useful when crashes aren’t predicted i.e. productionI Operators can debug crashes offlineI Allows archiving of crash data for later comparison

Core DumpsI Do not need to know what you are looking for ahead of timeI Need source tree, debug symbols and built kernel for analysis

Text DumpsI Less Complete but much smaller (A few MB vs Many GB)I Sometimes easier to extract information using DDB over kgdb.

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 18: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Illumos

Not a BSD but the features are alluringI Online dump size estimation

I Includes different calculations for settings, e.g. compressionI Compressed Dump

I gzip compressionI Dump to Swap on zvol

I Versatility of zvols vs partitionsI Live Dump

I Useful for production machines where interactive debugging is notpossible

I Especially for debugging hangs

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 19: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Mac OS X

I Very different from the BSD dump procedureI Mach-OI Local or remote (network or Firewire)

I netdump - kdumpd(8)I Using a modified tftpd(8) from FreeBSD!

I Compressed DumpI gzip compressionI Both local and using kdumpd(8).

I Full Procedure in paper

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 20: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Backtrace.io

I Backtrace.io curates kernel and userspace coresI Snapshots allow for debugging on a laptop instead on crashed

machineI Snapshots use automation to choose relevant sections of dump

I Allows for asking questions like:I Which panic is most common?I Correlated by datacenter? Storage Controller? Hard Drive Model?

Timestamp?

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 21: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Overview

I Who Am I?I BackgroundI The PastI The PresentI The Future

I Core Dump ExtensionsI Modular Dump CodeI netdumpI minidumpszI Compressed Dump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 22: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Extant Core Dump Extensions

I Modular Dump CodeI Embedded systemsI Mix and match features (compression but no netdump)I rgrimes@ for info

I netdumpI Started at Duke by Darrell AndersonI Holding on since FreeBSD 4.x (~2004)I Continued at Sandvine and then IsilonI Almost part of FreeBSD 9.0I markj@ for info

I minidumpsz - minidump size estimationI Compressed Dump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 23: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

minidumpsz

% sudo sh minidumpsize_10.1.shdebug.mini_dump_size: 138127282176 # 138.1 GB(!!!!)

I Dump Size EstimationI A “no op” version of the minidump code as a kernel module

I minidumpsz for FreeBSD 10 and 11I Should be upstreamed soonI Email for binary (rgrimes@ or [email protected])

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 24: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Compressed Dump

I “Save Compression”I gzip dump on the fly before landing in swap

I Compression Ratio 6:1 to 14:1I A 32 GB Core becomes 5.34 GB!I Fixing the patch so it applies to FreeBSD 12 after encrypted dump

will take some work

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 25: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Proposed Core Dump Extensions

I Dump to swap on zvolI gibbs@ offered to mentor me

I Live DumpI Gauge interest

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 26: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

How to use the appendix for Research

I Use the org-mode fileI Includes many of the commit messages, emails, and code referenced

I Bonus email: jkh@ calling this topic esoteric :)I Includes information on versions not referenced in paper

I UNIX v5 and other incomplete sectionsI Includes notes of various levels of detail

I Code is often included where applicable

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD

Page 27: The History and Future of Core Dumps in FreeBSD

Introduction Background The Past The Present The Future Conclusion

Links

I Thanks toI Deb Goodkin for bringing me into the FreeBSD CommunityI Rodney Grimes for help reading PDP-11 assemblyI Michael Dexter for coming up with this idea and for asking me to

thank him.I You for coming!

I github.com/gwydirsam/bsd-coredump-historyI github.com/dspinellis/unix-history-repoI people.freebsd.org/~rgrimes/index.html#kerneldump

Sam W. Gwydir, Texas A&M University [email protected]

The History and Future of Core Dumps in FreeBSD