Bug #15471
closed
Memory leak in pfSense module function ``pfSense_get_ifaddrs()``
Added by Jim Pingle 7 months ago.
Updated about 1 month ago.
Plus Target Version:
24.11
Description
Moving this over from #15459 since it does not appear to be a problem in LCDProc but in the base system pfSense PHP module.
There is a memory leak in the pfSense module function pfSense_get_ifaddrs()
. The function appears to leak some memory in certain contexts, and sometimes more/less memory than others. It's still unclear how/why but here are a few things that we seem to have determined so far:
- The function leaks 56 bytes on most calls, which happens to be the size of the
ifaddrs
struct, though the only apparent allocation made on that structure is also freed at the end.
- When run on some interfaces it leaks 112 bytes (2x56).
- When run on WireGuard interfaces it doesn't leak at all.
I checked some other similar functions and they did not appear to leak anything (e.g. pfSense_getall_interface_addresses()
does not leak) as far as I could tell.
While the amount of memory is small, the function gets run dozens/hundreds of times in certain code paths and since LCDProc runs indefinitely in a loop, it adds up significantly over time.
- Status changed from New to Feedback
- Assignee set to Kristof Provost
Was able to reproduce on 24.03 and 2.7.2 CE via calling the leaking function in endless loop.
tested on:
Version 2.8.0-DEVELOPMENT (amd64)
built on Thu May 16 5:30:00 UTC 2024
FreeBSD 15.0-CURRENT
This version fixes the issue
- Has duplicate Bug #15066: PHP allocation failure in pfsense-utils.inc added
- Assignee changed from Kristof Provost to Jim Pingle
- % Done changed from 0 to 100
A quick test of the function looks good compared to my previous tests, but I'd prefer to keep this open for now until we have Plus dev snapshots going to test since that's where I could reproduce it reliably in a more complete and practical way.
Reassigning to me since it's waiting on me to test.
- Plus Target Version changed from 24.07 to 24.08
- Status changed from Feedback to Resolved
Tested on a system where I could reproduce the problem before with LCDProc and even after 17 hours there is zero increased memory usage, where before it was showing increased usage almost immediately.
Seems safe to call this resolved.
- Plus Target Version changed from 24.08 to 24.11
Also available in: Atom
PDF