SkinSystem icon indicating copy to clipboard operation
SkinSystem copied to clipboard

Fixing huge memory leak.

Open azuraerae opened this issue 1 year ago • 7 comments

azuraerae avatar May 12 '23 21:05 azuraerae

Sorry, can you explain how would this prevent a "huge memory leak" ?

aljaxus avatar May 13 '23 18:05 aljaxus

Sorry, can you explain how would this prevent a "huge memory leak" ? @aljaxus

The last line called printErrorAndDie no matter how the disconnect happened, even if successful. The issue is that then, in libraries.php, it created a loop, as the curl function did not receive a response, and threw a new printErrorAndDie. This looped until it completely filled the PHP allocated memory, before printing an error in the error.log file of Apache.

azuraerae avatar May 16 '23 16:05 azuraerae

By "no matter how the disconnect happened", I mean when the disconnect button was pressed, even if the disconnect was successful, it called an error.

azuraerae avatar May 16 '23 16:05 azuraerae

By "no matter how the disconnect happened", I mean when the disconnect button was pressed, even if the disconnect was successful, it called an error.

What do you mean by "disconnect button"? The logout button?


I am a bit confused because there's no keyword "disconnect" in the SkinSystem codebase (so I have no clue what button you're talking about).

aljaxus avatar May 16 '23 16:05 aljaxus

Yes, the logout button, I am sorry. Basically, the file I edited (authenCore) takes care of the session, if I understood correctly. But when the session ends, no matter what, the printErrorAndDie function was fired. That caused it to call the curl function, which didn't have a $response and therefore called printErrorAndDie again, looping and filling up memory until it entirely filled the PHP allocated memory (memory leak, basically). The logouts would be painfully long, and also eat up a ton of ram server side.

azuraerae avatar May 16 '23 16:05 azuraerae

Yeah took a look and ... this is an issue every time printErrorAndDie is called, not just that instance of it being called at the end of the file?

The problem is that printErrorAndDie calls curl which could call printErrorAndDie which calls curl which could call printErrorAndDie etc...

The problem is not the removed line - it's the interaction between functions printErrorAndDie and curl.

aljaxus avatar May 16 '23 17:05 aljaxus

I get that printErrorAndDie calls curl which could itself call printErrorAndDie but on one condition: $response has to be false, and the only case where it happens to be false is with this (genuinely useless) line, since, well, there is no error...

azuraerae avatar May 16 '23 18:05 azuraerae