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

fix: depotchest memory leak #4510

Closed
wants to merge 2 commits into from
Closed

fix: depotchest memory leak #4510

wants to merge 2 commits into from

Conversation

lyuz1n
Copy link
Contributor

@lyuz1n lyuz1n commented Jul 23, 2023

Pull Request Prelude

Changes Proposed

items on depot cannot destroy after player logout.
after some relogins with around 100k items on depot...

BEFORE FIX:
Captura de tela 2023-07-23 164438

AFTER FIX:
Captura de tela 2023-07-23 164420

@ghost ghost requested review from DSpeichert, ranisalt, nekiro and MillhioreBT July 23, 2023 21:15
@nekiro
Copy link
Member

nekiro commented Jul 23, 2023

#3423
#3452

src/player.h Outdated Show resolved Hide resolved
Copy link
Contributor

@moviebr moviebr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

Copy link
Member

@nekiro nekiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will crash, because of double pointer deletion, one happens from container destructor, because depot is a regular item inside locker (you have to remove depot from locker on player destructor to avoid that) and the second will trigger from shared_ptr trying to delete assigned object

@ranisalt
Copy link
Member

@nekiro is right, if you're going to change to a shared ptr, you must change it everywhere or you will get nasty double frees

@ramon-bernardo
Copy link
Contributor

I ran some tests, and it seems that the code below solves this issue 👇🏻

Player::~Player()
{
	for (auto [_, depotChest] : depotChests) {
		delete depotChest;
	}
}

@nekiro
Copy link
Member

nekiro commented Dec 22, 2024

superseded by #4879

@nekiro nekiro closed this Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants