Bug 273224

Summary: After the process finishes shared memory resourced aren't released: shmget() failed: No space left on device
Product: Base System Reporter: Yuri Victorovich <yuri>
Component: kernAssignee: Yuri Victorovich <yuri>
Status: Closed Not A Bug    
Severity: Affects Only Me CC: kib, rb
Priority: ---    
Version: 13.2-STABLE   
Hardware: Any   
OS: Any   

Description Yuri Victorovich freebsd_committer freebsd_triage 2023-08-19 06:31:20 UTC
I use x11vnc which uses shmget(2).

The system was up for 2+ months and x11vnc was launched maybe hundreds of times.

Today it failed all of a sudden:
> shmget() failed: No space left on device

x11vnc is launched as a new process every time the user connects to the local display.

This means that when x11vnc finishes it doesn't release resources that shmget(2) allocates.

Ultimately shmget(2) becomes a time bomb which blows up eventually and x11vnc (and probably all other software that uses shmget(2)) becomes unusable until the system is rebooted.


FreeBSD 13.2


---References---
* Someone had the same problem on Linux 12 years ago: https://blog.dhampir.no/content/fixing-shmget-failed-no-space-left-on-device
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2023-08-19 15:04:38 UTC
Why do you think that this has something to do with the kernel?

If process does not clean up its SysV IPC shared memory segments, then they
would lay around, by the API design.  Use ipcs(8) to discover them, and ipcrm(8)
to remove unwanted segments.
Comment 2 Bob Bishop 2023-08-19 15:10:32 UTC
Unlike just about every other resource, shared memory segments are not released when a process exits; see _exit(2) and exit(3).

This (possibly astonishing) behaviour is unchanged since the introduction of SysV IPC around 1983.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2023-08-19 17:44:15 UTC
Ok, thanks.

I was under (false) impression that this has been fixed.

Thanks for the explanation,
Yuri