Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[defect]: Memory leak when reloading configuration using HUP signal #5490

Open
alexs20 opened this issue Jan 7, 2025 · 4 comments
Open

[defect]: Memory leak when reloading configuration using HUP signal #5490

alexs20 opened this issue Jan 7, 2025 · 4 comments
Labels
defect category: a defect or misbehaviour

Comments

@alexs20
Copy link

alexs20 commented Jan 7, 2025

What type of defect/bug is this?

Unexpected behaviour (obvious or verified by project member)

How can the issue be reproduced?

Tested using docker container freeradius/freeradius-server:3.2.6

  1. Run the container
  2. Attach to the container with another shell
  3. run ps -aux and remember the memory value in VSZ and PID
  4. modify and save /etc/freeradius/clients.conf (for example add some spaces)
  5. reload the configuration using kill -HUP <PID>
  6. run ps -aux again and compare the memory value in VSZ
  7. repeat steps 4,5,6 several times.

Result:
Starting from the second reload the VSZ will grow after each and every reload and never go back.

Log output from the FreeRADIUS daemon

not relevant

Relevant log output from client utilities

not relevant

Backtrace from LLDB or GDB

not relevant
@alexs20 alexs20 added the defect category: a defect or misbehaviour label Jan 7, 2025
@alandekok
Copy link
Member

Please verify that this is a leak, using something like valgrind. It is much more likely that the server is simply using more memory, which will eventually be cleaned up.

The server will clean up the memory, after max_request_time * 4. See the bottom of src/main/main_config.c

@alexs20
Copy link
Author

alexs20 commented Jan 7, 2025

Sorry, I am not familiar with valgrind. Working mostly with Java, not C.
But I can definitely confirm that it will never go back.
I ran a script while true; do echo ' ' >> /etc/freeradius/clients.conf && kill -HUP $FR_PID && sleep 5; done in one console
And top | grep freeradius in second.

From what you says, taking in account that max_request_time=30, it should go down after 2 minutes.

But here is the result after 5 minutes.

    110 radiusd   20   0  173628  86936  19960 S   0.0   0.5   0:02.22 freeradius                                                                                                             
    110 radiusd   20   0  174552  87992  19960 S   0.3   0.5   0:02.23 freeradius                                                                                                             
    110 radiusd   20   0  175608  89048  19960 S   0.3   0.5   0:02.24 freeradius                                                                                                             
    110 radiusd   20   0  175608  89048  19960 S   1.7   0.5   0:02.29 freeradius                                                                                                             
    110 radiusd   20   0  176676  90104  19960 S   0.3   0.6   0:02.30 freeradius                                                                                                             
    110 radiusd   20   0  176676  90104  19960 S   0.0   0.6   0:02.30 freeradius                                                                                                             
    110 radiusd   20   0  177600  91160  19960 S   0.3   0.6   0:02.31 freeradius                                                                                                             
    110 radiusd   20   0  178656  92216  19960 S   0.3   0.6   0:02.32 freeradius                                                                                                             
    110 radiusd   20   0  178656  92216  19960 S   0.0   0.6   0:02.32 freeradius                                                                                                             
    110 radiusd   20   0  179732  93008  19960 S   0.3   0.6   0:02.33 freeradius                                                                                                             
    110 radiusd   20   0  179732  93008  19960 S   0.0   0.6   0:02.33 freeradius                                                                                                             
    110 radiusd   20   0  180656  94064  19960 S   0.0   0.6   0:02.33 freeradius                                                                                                             
    110 radiusd   20   0  181712  95120  19960 S   0.3   0.6   0:02.34 freeradius                                                                                                             
    110 radiusd   20   0  181712  95120  19960 S   0.0   0.6   0:02.34 freeradius                                                                                                             
    110 radiusd   20   0  182780  96176  19960 S   0.0   0.6   0:02.34 freeradius                                                                                                             
    110 radiusd   20   0  182780  96176  19960 S   0.0   0.6   0:02.34 freeradius                                                                                                             
    110 radiusd   20   0  183704  97232  19960 S   0.3   0.6   0:02.35 freeradius                                                                                                             
    110 radiusd   20   0  184760  98288  19960 S   0.3   0.6   0:02.36 freeradius                                                                                                             
    110 radiusd   20   0  184760  98288  19960 S   0.0   0.6   0:02.36 freeradius                                                                                                             
    110 radiusd   20   0  185816  99080  19960 S   0.3   0.6   0:02.37 freeradius                                                                                                             
    110 radiusd   20   0  185816  99344  19960 S   0.0   0.6   0:02.37 freeradius                                                                                                             
    110 radiusd   20   0  186740 100136  19960 S   0.0   0.6   0:02.37 freeradius                                                                                                             
    110 radiusd   20   0  187796 101192  19960 S   0.7   0.6   0:02.39 freeradius                                                                                                             
    110 radiusd   20   0  187796 101192  19960 S   1.7   0.6   0:02.44 freeradius                                                                                                             
    110 radiusd   20   0  188852 102248  19960 S   0.0   0.6   0:02.44 freeradius                                                                                                             
    110 radiusd   20   0  188852 102248  19960 S   0.0   0.6   0:02.44 freeradius                                                                                                             
    110 radiusd   20   0  189776 103304  19960 S   0.3   0.6   0:02.45 freeradius                                                                                                             
    110 radiusd   20   0  190832 104360  19960 S   0.3   0.6   0:02.46 freeradius                                                                                                             
    110 radiusd   20   0  190832 104360  19960 S   0.0   0.6   0:02.46 freeradius                                                                                                             
    110 radiusd   20   0  191896 105416  19960 S   0.3   0.6   0:02.47 freeradius                                                                                                             
    110 radiusd   20   0  191896 105416  19960 S   0.0   0.6   0:02.47 freeradius                                                                                                             
    110 radiusd   20   0  192820 106208  19960 S   0.0   0.6   0:02.47 freeradius                                                                                                             
    110 radiusd   20   0  193876 107264  19960 S   0.3   0.7   0:02.48 freeradius                                                                                                             
    110 radiusd   20   0  193876 107264  19960 S   0.0   0.7   0:02.48 freeradius                                                                                                             
    110 radiusd   20   0  194932 108320  19960 S   0.3   0.7   0:02.49 freeradius                                                                                                             
    110 radiusd   20   0  194932 108320  19960 S   0.0   0.7   0:02.49 freeradius                                                                                                             
    110 radiusd   20   0  195856 109376  19960 S   0.0   0.7   0:02.49 freeradius                                                                                                             
    110 radiusd   20   0  196912 110432  19960 S   0.3   0.7   0:02.50 freeradius                                                                                                             
    110 radiusd   20   0  196912 110432  19960 S   0.0   0.7   0:02.50 freeradius                                                                                                             
    110 radiusd   20   0  197968 111488  19960 S   0.3   0.7   0:02.51 freeradius                                                                                                             
    110 radiusd   20   0  197968 111488  19960 S   0.0   0.7   0:02.51 freeradius                                                                                                             
    110 radiusd   20   0  198892 112280  19960 S   0.0   0.7   0:02.51 freeradius                                                                                                             
    110 radiusd   20   0  199948 113336  19960 S   0.3   0.7   0:02.52 freeradius                                                                                                             
    110 radiusd   20   0  199948 113336  19960 S   1.6   0.7   0:02.57 freeradius                                                                                                             
    110 radiusd   20   0  201004 114392  19960 S   0.3   0.7   0:02.58 freeradius                                                                                                             
    110 radiusd   20   0  201004 114392  19960 S   0.0   0.7   0:02.58 freeradius                                                                                                             
    110 radiusd   20   0  201928 115448  19960 S   0.3   0.7   0:02.59 freeradius                                                                                                             
    110 radiusd   20   0  202984 116504  19960 S   0.0   0.7   0:02.59 freeradius                                                                                                             
    110 radiusd   20   0  204040 117560  19960 S   0.3   0.7   0:02.60 freeradius                                                                                                             
    110 radiusd   20   0  204040 117560  19960 S   0.0   0.7   0:02.60 freeradius                                                                                                             
    110 radiusd   20   0  204964 118352  19960 S   0.3   0.7   0:02.61 freeradius                                                                                                             
    110 radiusd   20   0  206020 119408  19960 S   0.3   0.7   0:02.62 freeradius                                                                                                             
    110 radiusd   20   0  206020 119408  19960 S   0.0   0.7   0:02.62 freeradius                                                                                                             
    110 radiusd   20   0  207076 120464  19960 S   0.3   0.7   0:02.63 freeradius                                                                                                             
    110 radiusd   20   0  207076 120464  19960 S   0.0   0.7   0:02.63 freeradius                                                                                                             
    110 radiusd   20   0  208000 121520  19960 S   0.0   0.7   0:02.63 freeradius                                                                                                             
    110 radiusd   20   0  209056 122576  19960 S   0.3   0.7   0:02.64 freeradius                                                                                                             
    110 radiusd   20   0  209056 122576  19960 S   0.0   0.7   0:02.64 freeradius                                                                                                             
    110 radiusd   20   0  210112 123632  19960 S   0.0   0.8   0:02.64 freeradius                                                                                                             
    110 radiusd   20   0  211036 124424  19960 S   0.3   0.8   0:02.65 freeradius                                                                                                             
    110 radiusd   20   0  212092 125480  19960 S   0.3   0.8   0:02.66 freeradius                                                                                                             
    110 radiusd   20   0  212092 125480  19960 S   1.7   0.8   0:02.71 freeradius                                                                                                             
    110 radiusd   20   0  213152 126536  19960 S   0.3   0.8   0:02.72 freeradius                                                                                                             
    110 radiusd   20   0  213152 126536  19960 S   0.0   0.8   0:02.72 freeradius                                                                                                             
    110 radiusd   20   0  214076 127592  19960 S   0.3   0.8   0:02.73 freeradius                                                                                                             
    110 radiusd   20   0  215132 128648  19960 S   0.0   0.8   0:02.73 freeradius                                                                                                             
    110 radiusd   20   0  215132 128648  19960 S   0.0   0.8   0:02.73 freeradius                                                                                                             
    110 radiusd   20   0  216188 129704  19960 S   0.3   0.8   0:02.74 freeradius                                                                                                             
    110 radiusd   20   0  216188 129704  19960 S   0.0   0.8   0:02.74 freeradius                                                                                                             
    110 radiusd   20   0  217112 130496  19960 S   0.3   0.8   0:02.75 freeradius                                                                                                             
    110 radiusd   20   0  218168 131552  19960 S   0.3   0.8   0:02.76 freeradius                                                                                                             
    110 radiusd   20   0  218168 131552  19960 S   0.0   0.8   0:02.76 freeradius  

After 10 minutes i stopped the script and reverted the client.conf, and reloaded again.
Waited another 10 minutes. And nope it stays on very high value.

@alandekok
Copy link
Member

Hmm... well, this is a low priority issue. The short answer is don't HUP it that often, and if you're worried about memory, just restart it.

We're happy to take patches to fix the issue, but at this point, it's not enough of a priority for us to spend time debugging it.

@alexs20
Copy link
Author

alexs20 commented Jan 7, 2025

I see, no worries. You are right. My scenario is too extreme and we can always restart the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect category: a defect or misbehaviour
Projects
None yet
Development

No branches or pull requests

2 participants