---
name: "KASSERT"
section: "9freebsd"
platform: "linux"
package: "freebsd-manpages"
version: "12.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/KASSERT/9freebsd"
---

# KASSERT(9freebsd)

kernel expression verification macro

## NAME

**KASSERT** – kernel expression verification macro

## SYNOPSIS

**options INVARIANTS**

**#include \<sys/param.h\>**

**#include \<sys/systm.h\>**

**KASSERT**(*expression*, *msg*);

## DESCRIPTION

In a kernel compiled with **options INVARIANTS**, the **KASSERT**() macro tests the given *expression* and if it is false, calls the [panic(9)](/panic/9.md) function, terminating the running system.

In a kernel that does not have **options INVARIANTS**, the **KASSERT**() macro is defined to be a no-op. The second argument is a [printf(9)](/printf/9.md) format string and its arguments, enclosed in parentheses.

## EXAMPLES

The kernel function **vput**() must not be called with a NULL pointer.

```
void
vput(vp)
        struct vnode *vp;
{
	struct proc *p = curproc;
	KASSERT(vp != NULL, ("vput: null vp"));
	...
}
```

## SEE ALSO

[config(8)](/config/8.md), [panic(9)](/panic/9.md)

## AUTHORS

This manual page was written by Jonathan M. Bresler ⟨*jmb@FreeBSD.org*⟩.
