CRASHME(9) Kernel Developer's Manual CRASHME(9)

crashme, crashme_add, crashme_removein-kernel testing of crash handling

#include <sys/crashme.h>

int
crashme_add(crashme_node *cn);

int
crashme_remove(crashme_node *cn);

The crashme functions provide access to dynamically add and remove crashme nodes. These nodes are simply named callbacks that are expected to cause the system to crash.

The crashme functionality is only available in kernels with the options DEBUG set in the kernel config(5) file.

Each crashme node is maintained in a crashme_node structure which has the following public members:

typedef int (*crashme_fn)(int /* flags */);

typedef struct crashme_node {
        const char     *cn_name;
        const char     *cn_longname;
        crashme_fn      cn_fn;
} crashme_node;

The caller must fill in the cn_name, cn_longname, and cn_fn members.

The cn_fn function is passed flags parameter from sysctl. It shall return 0 upon success or non zero on failure.

The following sysctl(8) variables are provided by the crashme subsystem:

debug.crashme_enable
Must be set to 1 for any crashme node to be executed.

The following sysctl(8) variables trigger crashes in different ways when written to:

debug.crashme.panic
Call panic(9).
debug.crashme.null_deref
Dereference a null pointer.
debug.crashme.null_jump
Call a null function pointer, i.e., jump to the instruction address zero.
debug.crashme.ddb
Enter ddb(4) directly by calling (). Requires options DDB.

ddb(4), options(4), sysctl(8), panic(9).

The crashme driver appeared in NetBSD 9.0.

Matthew R. Green

January 7, 2019 NetBSD 11.0