rathena/rathena

Crash when mob cast skill

Closed this issue · 10 comments

rAthena Hash

13bc3e2

Client Date

20131120

Server Mode

Pre-Renewal

Result

image

this is my temp fix

static int8 skill_castend_id_check(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv) {
	std::shared_ptr<s_skill_db> skill = skill_db.find(skill_id);

#ifdef 1
	if (nullptr == skill) // invalid skill id
		return USESKILL_FAIL_MAX;
#endif
	...

Relevant Log Output

See picture above

Expected Result

It should not crash

How to Reproduce

When mob cast character lock-on skill, map will crash
maybe unit.cpp line 2857 cause this.

Official Information

N/A

Modifications that may affect results

#define RENEWAL_CAST

Do you have something custom calling this? You have skill_lv=3 and skill_id=0 being passed to this function.

Somehow you are either clearing ud->skill_id or not properly accounting for something from skill_castend_id. We could add nullptr checks here but technically you shouldn't be failing to look up skills in these locations. If you are the crash is valid and it's a result of a problem somewhere else.

nothing, the bug happens after #8302.

I think this is ffe40de#diff-7aa01f32243f325129ff31983fd8166d61e578b8e7855fa7c8684f5c346b5167R2857 the problem

You clearly have modifications in your file:

Line 13348 of skill.cpp is:

						case TR_METALIC_FURY: // Don't know the official increase. For now lets do up to 50% increase.

Nevertheless I think you are right.

@mrpond Any idea which monster skill is causing this?

skill_id gets cleared when a monster does a normal attack, it shouldn't happen while a skill is currently being processed, but above looks like it's some kind of skill that creates a timer and then expects the skill_id to still be set at the end of the timer.

Edit: Actually usually the timer here is usually the end of the casttime. But that would mean the monster must have managed to do a successful normal attack while casting. Hmm.

Is skill.cpp line 13348 in your source code this?

		// Failing
		if (fail || (res = skill_castend_id_check(src, target, ud->skill_id, ud->skill_lv)) >= 0) {
			if (sd && res != USESKILL_FAIL_MAX)
				clif_skill_fail( *sd, ud->skill_id, (enum useskill_fail_cause)res );
			break;
		}

@Playtester here skill.cpp skill.zip

That file also doesn't contain a skill_castend_id_check call in line 13348.

But I assume it's the section I quoted.

Would still need to know what skill causes this. Can you reproduce it with a certain skill?

Do you allow monsters to attack while casting? Is it when the spell gets cast-cancelled?

The issue can be reproduced when a player has the "Freecast" ability, but not sure how it happens with monsters. Still should be fixed so that we don't set it to 0 when a skilltimer exists.

I'll propose the following fix:

		// Only reset skill_id here if no skilltimer is currently ongoing
		if (ud->skilltimer == INVALID_TIMER)
			ud->skill_id = 0;

Can you check if the linked PR fixes the issue for you?

Can you check if the linked PR fixes the issue for you?

yes, we'll test it on production server (1800 Players) for you.

@Playtester if you had time, #8310
kindly look into this and make PR. I add some fix about bot/custom client can bypass pin code system.

I'll notify Lemon about that one.