Skip to content

Core/Pet: Attempt to fix assertions triggered when summoning pets#26501

Merged
jackpoz merged 11 commits into
TrinityCore:3.3.5from
jackpoz:fixes/pet-resummon
May 10, 2021
Merged

Core/Pet: Attempt to fix assertions triggered when summoning pets#26501
jackpoz merged 11 commits into
TrinityCore:3.3.5from
jackpoz:fixes/pet-resummon

Conversation

@jackpoz

@jackpoz jackpoz commented May 2, 2021

Copy link
Copy Markdown
Member

Changes proposed:

Target branch(es): 3.3.5/master

  • 3.3.5
  • master

Issues addressed:

Closes # (insert issue tracker number)
#26491

Tests performed:

  • Case 1 01530be (handled with generic code in Pet.cpp)
    • get a player with pet, by example warlock and summon pet
    • do command .cast 6962
    • do command .save
  • Case 2 db3898c (handled with generic code in Pet.cpp)
    • get a hunter with a tamed pet
    • .npc add temp 34775
    • mount in vehicle and switch to right or left seat
    • cast Call Pet hunter spell (.cast 883)
    • cast Call Stabled Pet (.cast 62757)
    • keep the pet in the stable
    • dismount vehicle
    • do .save
  • Case 3 db3898c (handled with generic code in Pet.cpp)
    • get a hunter with a tamed pet
    • cast Call Stabled Pet (.cast 62757)
    • keep the pet in the stable
    • do command .cast 6962
    • do command .save
  • Case 4 3435faf (handled with generic code in Pet.cpp)
    • get a warlock, summon a pet (by example imp)
    • .die on warlock character
    • (now you are dead, so use /g to talk on guild chat and use commands)
    • .cast 6962 triggered
    • .revive
    • summon a different pet (by example voidwalker)
    • use a mount
    • dismount
  • Case 5 3435faf (handled with generic code in Pet.cpp)
    • get a warlock and summon a pet (by example imp)
    • .npc add temp 34775
    • mount in vehicle and switch to right or left seat
    • summon a different pet (by example voidwalker)
  • Case 6 b9f1dba (handled with generic code in Player.cpp)
    • create a new warlock character
    • summon a pet (by example imp)
    • mount on a vehicle that allow use spells (by example 34775) and switch to left or right
    • passenger seat
    • cast any other summon pet (by example summon voidwalker)

Known issues and TODO list: (add/remove lines as needed)

  • More cases should be tested

@jackpoz

jackpoz commented May 2, 2021

Copy link
Copy Markdown
Member Author

Thanks @Jildor for the clear and easy How To Reproduce steps 👍

@Jildor

Jildor commented May 3, 2021

Copy link
Copy Markdown
Contributor

thanks ;)

I'm not sure but maybe HandleStableSwapPet needs the same as HandleStablePet?

@Jildor

Jildor commented May 3, 2021

Copy link
Copy Markdown
Contributor

get a hunter with a tamed pet
cast Call Stabled Pet (.cast 62757)
keep the pet in the stable
do command .cast 6962
do command .save
I think is related with laspetnumber, maybe we should setlaspetnumber(0) inside HandleStablePet after removepet?

I don't know how many more cases there may be, can't we look for a more generic solution?

@jackpoz

jackpoz commented May 3, 2021

Copy link
Copy Markdown
Member Author

I don't have a generic solution, I'm just trying to fix the crashes quite fast so worldserver can stay alive.
One thing about spell 6962 is that it has a custom SpellScript that deals with loading the pet and that code seems to cause a lot of these crashes.

@jackpoz

jackpoz commented May 3, 2021

Copy link
Copy Markdown
Member Author

get a hunter with a tamed pet
cast Call Stabled Pet (.cast 62757)
keep the pet in the stable
do command .cast 6962
do command .save

@Jildor to me this is a bug in spell 6962 that it doesn't do the same checks that "Call Pet" does, saying "You do not have a pet to summon"

@jackpoz

jackpoz commented May 3, 2021

Copy link
Copy Markdown
Member Author

get a hunter with a tamed pet
cast Call Stabled Pet (.cast 62757)
keep the pet in the stable
do command .cast 6962
do command .save

@Jildor this case has been fixed, now no pet is summoned if it's stabled

@jackpoz

jackpoz commented May 5, 2021

Copy link
Copy Markdown
Member Author

get a warlock, summon a pet (by example imp)
.die on warlock character
(now you are dead, so use /g to talk on guild chat and use commands)
.cast 6962 triggered
.revive
summon a different pet (by example voidwalker)
use a mount
dismount

@Jildor this case has been fixed too. Maybe someone with more knowledge about the code could find a different fix but at least we have some workarounds to avoid the crashes

@jackpoz jackpoz marked this pull request as ready for review May 5, 2021 19:59
@Jildor

Jildor commented May 6, 2021

Copy link
Copy Markdown
Contributor

yep, nice 👍
The problem is that there are more ways to generate these crashes, unfortunately I am unable to reproduce all of them, you can reproduce this easily too: #26492 (comment)

get a warlock and summon a pet (by example imp)
.npc add temp 34775
mount in vehicle and switch to right or left seat
summon a different pet (by example voidwalker)

It's too hard to find more ways to reproduce these crashes

@jackpoz

jackpoz commented May 6, 2021

Copy link
Copy Markdown
Member Author

@Jildor well the first step is to fix fast the obvious ones, then find a more generic solution that still works with all the cases we found (and ofc remove the fast temporary fix)

@jackpoz

jackpoz commented May 6, 2021

Copy link
Copy Markdown
Member Author

get a warlock and summon a pet (by example imp)
.npc add temp 34775
mount in vehicle and switch to right or left seat
summon a different pet (by example voidwalker)

this is fixed now with a more generic "when loading a pet from PET_SAVE_NOT_IN_SLOT and CurrentPet is not empty, remove the CurrentPet".

got a strange behavior now:

  • summon pet A with warlock
  • enter vehicle 34775
  • change seat to the ones where you can cast spells
  • summon pet B
  • exit vehicle
  • mount a normal mount
  • dismount
  • pet A is resummoned instead of pet B

but I guess summoning the wrong pet is better than triggering an assert

@jackpoz

jackpoz commented May 6, 2021

Copy link
Copy Markdown
Member Author

@Jildor I changed the fix for Case 1 to be more generic, moving the check in Pet.cpp .

@jackpoz

jackpoz commented May 8, 2021

Copy link
Copy Markdown
Member Author
  • get a hunter with a tamed pet
  • cast Call Stabled Pet (.cast 62757)
  • keep the pet in the stable
  • do command .cast 6962
  • do command .save

This case is now handled in a generic way, unstabling the pet and updating the required variables to avoid any assert. If this is not the desired behavior, just return false in Pet::LoadFromDB() in the "if" case I added (I'm not caring at all for blizzlikeness right now, just fixing asserts)

@jackpoz

jackpoz commented May 8, 2021

Copy link
Copy Markdown
Member Author

Case 2 now works with the same fix as Case 3, even if ingame it looks a bit strange. When dismounting, the stable pet will become current and the stable interface shows the pet duplicated until Call Stable is called again.

I removed the change added in 6052cdf which can be added again if needed (no idea if returnReagents parameter should be false or true in that case)

@jackpoz

jackpoz commented May 8, 2021

Copy link
Copy Markdown
Member Author

Case 4 now works with the same fix as Case 5. This means we have 5 different cases fixed by 3 different changes, all done in Pet::LoadPetFromDB() :

  • if the pet being loaded is already the current one, don't re-summon the same one
  • if there is already a pet, remove it
  • if the pet is stabled, unstable it

These are fallback checks that kick in only when the caller has not taken care already of these scenarios. For example Call Pet will still show the ingame message "You don't have an active pet" when the pet is stabled.

@Jildor could you please test latest version of this PR, running once more through the cases you reported and maybe some more that didn't crash before but that you tested already ? I hope the current code looks more promising to you 🤞

@jackpoz jackpoz changed the title Core/Pet: Attempt to fix an assertion triggered when re-summoning the current pet Core/Pet: Attempt to fix assertions triggered when summoning pets May 8, 2021
@Jildor

Jildor commented May 9, 2021

Copy link
Copy Markdown
Contributor

this case continue crashing:
#26492 (comment)

@jackpoz

jackpoz commented May 9, 2021

Copy link
Copy Markdown
Member Author

@Jildor that case works for me using 770bda9

bMGC2W7zwe.mp4

@jackpoz

jackpoz commented May 9, 2021

Copy link
Copy Markdown
Member Author
  • create a new warlock character
  • summon a pet (by example imp)
  • mount on a vehicle that allow use spells (by example 34775) and switch to left or right
  • passenger seat
  • cast any other summon pet (by example summon voidwalker)

@Jildor case 6 fixed too

@Jildor

Jildor commented May 10, 2021

Copy link
Copy Markdown
Contributor

tested all cases, I can't reproduce the crashes 👍

@jackpoz jackpoz merged commit e203ecd into TrinityCore:3.3.5 May 10, 2021
@ghost

ghost commented May 10, 2021

Copy link
Copy Markdown

Thank you for the PR! 😄

@shenhuyong

Copy link
Copy Markdown

A new case:

  • create a new hunter character
  • .cast 1515 to tame a pet
  • .cast 62757 and put the pet into the stable
  • .cast 1515 to tame a new pet
  • .cast 62757
  • swap slots between new and old pets then server will crash

@jackpoz

jackpoz commented May 11, 2021

Copy link
Copy Markdown
Member Author

@shenhuyong did that case happen before this PR too ?

Edit: nvm, found the issue from this PR

@jackpoz

jackpoz commented May 11, 2021

Copy link
Copy Markdown
Member Author
  • create a new hunter character
  • .cast 1515 to tame a pet
  • .cast 62757 and put the pet into the stable
  • .cast 1515 to tame a new pet
  • .cast 62757
  • swap slots between new and old pets then server will crash

fixed by 22a5b0f , caused by a missing change from this PR in Pet Swap opcode

@jackpoz jackpoz deleted the fixes/pet-resummon branch December 18, 2021 11:35
Shauren pushed a commit that referenced this pull request Jan 30, 2022
…6501)

* Core/Pet: Attempt to fix an assertion triggered when re-summoning the current pet

* Core/Pet: Attempt to fix an assertion triggered when stabling a pet while in a vehicle

* Core/Pet: Attempt to fix an assertion triggered when stabling a pet and casting spell 6962

* Core/Pet: Attempt to fix an assertion triggered when casting spell 6962 while being dead

* Core/Pet: Attempt to fix an assertion triggered when summoning a pet while on vehicle 34775

* Handle cases in a generic way

* Code cleanup

* Core/Pet: Attempt to fix an assertion triggered when summoning a pet while on vehicle 34775 with a new character

(cherry picked from commit e203ecd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants