The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=18c5a26f8a747583b9bca3a6a1ae9db1ed4591a3
commit 18c5a26f8a747583b9bca3a6a1ae9db1ed4591a3 Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-05-06 22:53:59 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-05-07 17:00:14 +0000 vm_map_growstack(): give a hint to user that stack was blown out Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56863 --- sys/vm/vm_map.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 0a81e62d2d63..7ead7d7e6472 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -4723,6 +4723,11 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, return (rv); } +static bool report_stackoverflow = true; +SYSCTL_BOOL(_vm, OID_AUTO, report_stackoverflow, CTLFLAG_RWTUN, + &report_stackoverflow, 0, + "uprintf() on stack overflow"); + /* * Attempts to grow a vm stack entry. Returns KERN_SUCCESS if we * successfully grow the stack. @@ -4787,8 +4792,12 @@ retry: if (guard > max_grow) return (KERN_NO_SPACE); max_grow -= guard; - if (grow_amount > max_grow) + if (grow_amount > max_grow) { + if (report_stackoverflow) + uprintf("pid %d comm %s tid %d stack overflow\n", + p->p_pid, p->p_comm, td->td_tid); return (KERN_NO_SPACE); + } /* * If this is the main process stack, see if we're over the stack @@ -4796,8 +4805,12 @@ retry: */ is_procstack = addr >= (vm_offset_t)vm->vm_maxsaddr && addr < (vm_offset_t)vm->vm_stacktop; - if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim)) + if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim)) { + if (report_stackoverflow) + uprintf("pid %d comm %s tid %d stack overflow\n", + p->p_pid, p->p_comm, td->td_tid); return (KERN_NO_SPACE); + } #ifdef RACCT if (racct_enable) {
