Bug 291683 - FreeBSD 15.0-RELEASE: system hangs when performing stress-ng utime stress tests
Summary: FreeBSD 15.0-RELEASE: system hangs when performing stress-ng utime stress tests
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-15 11:03 UTC by Colin Ian King
Modified: 2026-01-27 22:17 UTC (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Ian King 2025-12-15 11:03:44 UTC
Running the stress-ng utime stressor causes the 15.0 kernel to hang:

to reproduce this issue:

git clone https://github.com/ColinIanKing/stress-ng
cd stress-ng
gmake clean
gmake -j $(nproc)
./stress-ng --utime -t 60 --verify

.. test locks up the kernel

Tested in QEMU, 8 CPUs, 4GB RAM, amd64
Comment 1 Colin Ian King 2025-12-15 11:05:33 UTC
Using IDE drive emulation
Comment 2 Colin Ian King 2025-12-15 11:28:04 UTC
Simple reproducer, run this with vmstat 1 and it shows the free memory reducing and eventually we run out of memory with various services getting killed.

#include <fcntl.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
	struct timeval timevals[2];
	char filename[] = "testfile";
	int fd;
	
	(void)unlink(filename);
	fd = creat(filename, 0777);
	if (fd < 0) {
		fprintf(stderr, "faile to creat %s\n", filename);
		exit(1);
	}

	for (;;) {
		gettimeofday(&timevals[0], NULL);
		timevals[1] = timevals[0];
		utimes(filename, timevals);
	}
}
Comment 3 Marek Zarychta 2025-12-15 12:16:39 UTC
(In reply to Colin Ian King from comment #2)

stress.c:12:8: warning: call to undeclared function 'unlink'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   12 |         (void)unlink(filename);
      |               ^
1 warning generated.

You forgot about including <unistd.h>
Please add #include <unistd.h> and you will be fine.
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2025-12-22 00:55:38 UTC
^Triage: to submitter: does the recommended change fix your problem?
Comment 5 Colin Ian King 2025-12-22 11:47:36 UTC
(In reply to Mark Linimon from comment #4)

Adding the <unistd.h> and running the resulting program will still lead to the kernel running out of memory and hanging.  The problem is not in the example code I provided, the issue seems to be a resource leak that causes the kernel to hang.
Comment 6 Marek Zarychta 2025-12-22 14:36:17 UTC
(In reply to Colin Ian King from comment #5)
I have been running your code for several hours on arm64, but so far can't spot any leaks or exhaustion. Giving it a short try on adm64 also doesn't ring any bells. 
How long do I need to run one process of this PoC code to observe regression?
Comment 7 Colin Ian King 2025-12-22 14:55:32 UTC
On amd64 it took about 5 minutes to fully run out of memory
Comment 8 Marek Zarychta 2025-12-22 20:29:21 UTC
(In reply to Colin Ian King from comment #7)
I apologise, but I am unable to reproduce it within a finite time.
Comment 9 Mateusz Guzik freebsd_committer freebsd_triage 2025-12-23 17:40:22 UTC
This does not reproduce for me.

Can you clarify which filesystem the file resides on in your case? (notably is it ufs, zfs or tmpfs). Apart from that, does the utimes syscall succeed?

Since it takes few minutes to get there, can you validate halfway through if it is kernel memory or process RSS going up? top should show both

If this is kernel stuff, then "vmstat -mz" from fresh boot vs after things start getting bad for comparison should help out here.