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

Server crash after invalid items had been detected #86

Open
vilarion opened this issue Feb 14, 2022 · 2 comments
Open

Server crash after invalid items had been detected #86

vilarion opened this issue Feb 14, 2022 · 2 comments

Comments

@vilarion
Copy link
Member

Feb 14 18:07:36 Player (err): Player xxxxxxx(xxxxxxxxx) has invalid depot contents 2!
Feb 14 18:07:36 Player (err): Exception on loading player: std::exception
Feb 14 18:07:36 Other (err): SIGSEGV received! Last Script: npc.iradona_goldschein
Feb 14 18:07:36 terminate called without an active exception
@vilarion vilarion added the bug label Feb 14, 2022
@vilarion
Copy link
Member Author

May have happened because of manual item deletion by Slightly. Still the db should not get into an invalid state.

@dayjaby
Copy link
Contributor

dayjaby commented Feb 15, 2022

The combination of

            auto depotIt = depotContents.find(depot.first);

            if (depotIt != depotContents.end()) {
                depotIt->second = depot.second;
            }
        }

and

        for (rit = depots.rbegin(); rit != depots.rend(); ++rit) {
            delete rit->second;
        }

        for (rit2 = depotContents.rbegin(); rit2 != depotContents.rend(); ++rit2) {
            delete rit2->second;
        }

looks like some pointers are deleted twice.

Verified the issue here: https://gist.github.com/dayjaby/792d80b409ab15d198ea42490c330346

$ g++ broken.cpp -o broken && ./broken
1 constructed
2 constructed
Trying to delete container 2
2 destructed
Trying to delete container 0
0 destructed
free(): double free detected in tcache 2
Abgebrochen (Speicherabzug geschrieben)

$ g++ fixed.cpp -o fixed && ./fixed
1 constructed
2 constructed
1 destructed
2 destructed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants