10.7. Debugging Deadlocks

You may experience so called deadlocks, the situation where a system stops doing useful work. To provide a helpful bug report in this situation, use ddb(4) as described above. Include the output of ps and trace for suspected processes in the report.

If possible, consider doing further investigation. The receipt below is especially useful if you suspect that a deadlock occurs in the VFS layer. Add the following options

makeoptions		DEBUG=-g
	options		INVARIANTS
	options		INVARIANT_SUPPORT
	options		WITNESS
	options		WITNESS_SKIPSPIN
	options		DEBUG_LOCKS
	options		DEBUG_VFS_LOCKS
	options		DIAGNOSTIC

to the kernel configuration file. When a deadlock occurs, in addition to the output of the ps command, provide information from the show pcpu, show allpcpu, show locks, show alllocks, show lockedvnods and alltrace.

To obtain meaningful backtraces for threaded processes, use thread thread-id to switch to the thread stack, and do a backtrace with where.

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.