Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Bugfixes "Segfault when debug-killing mon_yugg"

Open czyjanek opened this issue 6 months ago • 2 comments

Summary

Bugfixes "Segfault when debug-killing mon_yugg"

Purpose of change

Fixes #80911

Describe the solution

Describe alternatives you've considered

  1. Making a monster the alpha_talker.
  2. Adding check for nullptr alpha_talker before trying to activate EoC

Allowing for null talker is easier than making yugg the alpha_talker. Second option is a good alternative.

Testing

  1. Spawned yugg
  2. Debug-killed the monster
  3. Got debug messege that talker is null
  4. The game didn't crash afterward.

Additional context

czyjanek avatar Jun 09 '25 10:06 czyjanek

For me it looks like the opposite of fixing it, is there a reason old handling do not work? It itself was part of a fix, see #75295

UPD: yeah i fully remembered what was the issue, and the actual issue here is that if you check EOC_YUGG_DEATH, the only effect that uses alpha talker is condition player_see_u; it was added to prevent message appearing if you do not see yugg dying; i suspect that player_see_u need additionally check if alpha talker is even presented, and if not, return false (you cannot see if you do not exist)

GuardianDll avatar Jun 09 '25 10:06 GuardianDll

I was not happy with my solution; that's why I put it into the draft. After some digging I realized that adding null alpha talker into the dialogue does not solves the issue and it just masks the problem. The actual problem is in condition.cpp. Pretty much whole code in the file assumes that const_actor returns valid, not nullptr value but it is not true. In 2 cases it will return nullptr:

  1. is_beta == true; has_beta == false;
  2. is_beta == false; has_alpha == false;

Edit 1. The function const_actor warns about this problem, but it is not checked by other functions.

czyjanek avatar Jun 09 '25 11:06 czyjanek

Superseded by #81774

GuardianDll avatar Jul 14 '25 15:07 GuardianDll