Project

General

Profile

Actions

Bug #15471

closed

Memory leak in pfSense module function ``pfSense_get_ifaddrs()``

Added by Jim Pingle 7 months ago. Updated about 1 month ago.

Status:
Resolved
Priority:
High
Assignee:
Category:
PHP Interpreter
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
24.11
Release Notes:
Default
Affected Version:
Affected Architecture:

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.


Related issues

Has duplicate Bug #15066: PHP allocation failure in pfsense-utils.incDuplicate

Actions
Actions

Also available in: Atom PDF