libdiskmgt leaks PROM device information handles like a sieve
findevs() routine, we call
di_prom_init() to get a PROM device information handle. This handle is stored in the
struct search_args, but does not appear to be cleaned up afterwards.
For potentially flimsy reasons,
/dev/openprom allows at most 32 handles to be opened at once; a persistent process which uses
libdiskmgmt without exiting can end up hanging on to a lot of these handles. While it's conceivable that
/dev/openprom should be more flexible, it's assuredly not correct to leak these handles.
Updated by Joshua M. Clulow about 1 month ago
Note that if you're hitting this condition and all
/dev/openprom handles are in use,
prtconf -d will fail to work:
$ prtconf -d System Configuration: i86pc Memory size: 32658 Megabytes System Peripherals (Software Nodes): prtconf: di_prom_init() failed.: Resource temporarily unavailable
Updated by Garrett D'Amore about 1 month ago
I remember running across that limit many years ago and being confounded by it. There is no real reason for it, and it's a shame that it's set so low.
Having said that -- we should definitely fix the bug. But we could probably change the code to support a vastly larger number of cloned file handles. I expect it would be almost trivial to fix that limit.