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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when SaveRespawnTimeImmediately config option is set to 0 #542

Closed

Conversation

insunaa
Copy link
Contributor

@insunaa insunaa commented Jun 5, 2022

馃嵃 Pullrequest

This PR fixes a crash that occurs when SaveRespawnTimeImmediately is set to 0

How2Test

  • Compile this PR
  • Set SaveRespawnTimeImmediately to 0 in mangosd.conf
  • Observe that it does no longer crash

if (remove)
{
// if option set then object already saved at this moment
if (!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY))
obj->SaveRespawnTime();

obj->ResetMap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is unnecessary because obj is getting deleted right afterwards anyway, but maybe there was method to the madness, hence I kept it in both branches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I vote for removing this, since the destructor called by delete can invoke m_currMap->RemoveFromOnEventNotified(this);

@killerwife
Copy link
Contributor

Can you please post the stack trace?

@insunaa
Copy link
Contributor Author

insunaa commented Jun 5, 2022

#0  Map::GetPersistentState (this=0x0) at ../src/game/Maps/Map.h:233
No locals.
#1  0x000055555644c903 in Creature::SaveRespawnTime (this=0x7fffc201a380) at ../src/game/Entities/Creature.cpp:2186
No locals.
#2  0x0000555555ea3a7c in Map::Remove<Creature> (this=0x55556fe3cf90, obj=0x7fffc201a380, remove=true) at ../src/game/Maps/Map.cpp:917
        p = {x_coord = 384, y_coord = 521}
        cell = {data = {Part = {grid_x = 24, grid_y = 32, cell_x = 0, cell_y = 9, nocreate = 0, reserved = 0}, All = 2361368}}
        grid = 0x7fffc1fa2f70
#3  0x0000555555e994d9 in Map::RemoveAllObjectsInRemoveList (this=0x55556fe3cf90) at ../src/game/Maps/Map.cpp:1294
        obj = 0x7fffc201a380
#4  0x0000555555e5b938 in MapManager::RemoveAllObjectsInRemoveList (this=0x55555e95eb20) at ../src/game/Maps/MapManager.cpp:230
        i_map = {first = {nMapId = 530, nInstanceId = 0}, second = 0x55556fe3cf90}
        __range1 = std::map with 3 elements = {[{nMapId = 0, nInstanceId = 0}] = 0x55556cf842f0, [{nMapId = 1, nInstanceId = 0}] = 0x55556fe139a0, [{nMapId = 530, nInstanceId = 0}] = 0x55556fe3cf90}
        __begin1 = {first = {nMapId = 530, nInstanceId = 0}, second = 0x55556fe3cf90}
        __end1 = {first = {nMapId = 3, nInstanceId = 0}, second = 0x64}
#5  0x00005555560e77b9 in World::Update (this=0x555556c09800, diff=50) at ../src/game/World/World.cpp:1622
No locals.
#6  0x0000555555c6595c in WorldRunnable::run (this=0x55557a207b30) at ../src/mangosd/WorldRunnable.cpp:55
        diffTick = 50
        diffTime = 0
        overCounter = 0
#7  0x0000555555cb6abe in MaNGOS::Thread::ThreadTask (param=0x55557a207b30) at ../src/shared/Threading.cpp:84
        _task = 0x55557a207b30
#8  0x0000555555cb7c95 in std::__invoke_impl<void, void (*)(void*), void*> (__f=@0x55557a3028c0: 0x555555cb6aa0 <MaNGOS::Thread::ThreadTask(void*)>, __args=@0x55557a3028b8: 0x55557a207b30) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
No locals.
#9  0x0000555555cb7be2 in std::__invoke<void (*)(void*), void*> (__fn=@0x55557a3028c0: 0x555555cb6aa0 <MaNGOS::Thread::ThreadTask(void*)>, __args=@0x55557a3028b8: 0x55557a207b30) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
No locals.
#10 0x0000555555cb7ba2 in std::thread::_Invoker<std::tuple<void (*)(void*), void*> >::_M_invoke<0ul, 1ul> (this=0x55557a3028b8) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_thread.h:252
No locals.
#11 0x0000555555cb7b55 in std::thread::_Invoker<std::tuple<void (*)(void*), void*> >::operator() (this=0x55557a3028b8) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_thread.h:259
No locals.
#12 0x0000555555cb7a19 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*), void*> > >::_M_run (this=0x55557a3028b0) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_thread.h:210
No locals.
#13 0x00007ffff76d6183 in std::execute_native_thread_routine (__p=0x55557a3028b0) at /usr/src/debug/gcc/libstdc++-v3/src/c++11/thread.cc:82
        __t = <optimized out>
#14 0x00007ffff728c54d in start_thread (arg=<optimized out>) at pthread_create.c:442
        ret = <optimized out>
        pd = <optimized out>
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140736517928512, 3200875025986206370, 140737488338766, 0, 140737488338767, 140736509538304, -3200855712039978334, -3200893092377281886}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#15 0x00007ffff7311b14 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100
No locals.

killerwife pushed a commit to cmangos/mangos-classic that referenced this pull request Jun 27, 2022
@insunaa insunaa deleted the fix-delayed-respawnsave-crash branch July 3, 2022 14:35
miraco pushed a commit to miraco/mangos-tbc that referenced this pull request Jul 8, 2022
BadgerBoy81 pushed a commit to BadgerBoy81/mangos-classic that referenced this pull request Jul 20, 2022
killerwife pushed a commit to cmangos/mangos-wotlk that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants