SkinsRestorer / SkinSystem

The Minecraft SkinSystem for SkinsRestorer
MIT License
131 stars 47 forks source link

Fixing huge memory leak. #139

Open azuraerae opened 1 year ago

aljaxus commented 1 year ago

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

azuraerae commented 1 year ago

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 commented 1 year ago

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.

aljaxus commented 1 year ago

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).

azuraerae commented 1 year ago

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.

aljaxus commented 1 year ago

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.

azuraerae commented 1 year ago

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...