JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.04k stars 617 forks source link

JASP: Segfault at PM_AnimLength if gripping and pushing #786

Open Civil opened 8 years ago

Civil commented 8 years ago
Program received signal SIGSEGV, Segmentation fault.
0x00007fffcfdee148 in PM_AnimLength (index=0, anim=4294967295) at /home/civil/src/OpenJK-civil/code/game/bg_panimate.cpp:4381
4381            return level.knownAnimFileSets[index].animations[anim].numFrames * abs(level.knownAnimFileSets[index].animations[anim].frameLerp);
(gdb) backtrace
#0  0x00007fffcfdee148 in PM_AnimLength (index=0, anim=4294967295) at /home/civil/src/OpenJK-civil/code/game/bg_panimate.cpp:4381
#1  0x00007fffcfc23a91 in NPC_ChoosePainAnimation (self=0x7fffd070c0b0 <g_entities+523600>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, damage=9, mod=40, hitLoc=0, 
    voiceEvent=-1) at /home/civil/src/OpenJK-civil/code/game/NPC_reactions.cpp:382
#2  0x00007fffcfc25688 in NPC_Pain (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, damage=9, 
    mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/NPC_reactions.cpp:547
#3  0x00007fffcf878129 in NPC_Jedi_Pain (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, 
    damage=9, mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/AI_Jedi.cpp:6083
#4  0x00007fffcfa28ed4 in GEntity_PainFunc (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, attacker=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, 
    damage=9, mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/g_functions.cpp:355
#5  0x00007fffcfa16d33 in G_Damage (targ=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, attacker=0x7fffd068c360 <g_entities>, dir=0x7fffffff23c0, 
    point=0x7fffffff23e0, damage=9, dflags=2, mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/g_combat.cpp:6807
#6  0x00007fffcfd3f6dd in WP_ForcePowerRun (self=0x7fffd068c360 <g_entities>, forcePower=FP_GRIP, cmd=0x7fffffff673c) at /home/civil/src/OpenJK-civil/code/game/wp_saber.cpp:13753
#7  0x00007fffcfd38871 in WP_ForcePowersUpdate (self=0x7fffd068c360 <g_entities>, ucmd=0x7fffffff673c) at /home/civil/src/OpenJK-civil/code/game/wp_saber.cpp:14355
#8  0x00007fffcf98d572 in ClientThink_real (ent=0x7fffd068c360 <g_entities>, ucmd=0x7fffffff673c) at /home/civil/src/OpenJK-civil/code/game/g_active.cpp:5265
#9  0x00007fffcf9946ec in ClientThink (clientNum=0, ucmd=0x7fffffff673c) at /home/civil/src/OpenJK-civil/code/game/g_active.cpp:5696
#10 0x000000000063fb81 in SV_ClientThink (cl=0x63300008c820, cmd=0x7fffffff673c) at /home/civil/src/OpenJK-civil/code/server/sv_client.cpp:399
#11 0x0000000000640c8a in SV_UserMove (cl=0x63300008c820, msg=0x7fffffffba60) at /home/civil/src/OpenJK-civil/code/server/sv_client.cpp:520
#12 0x000000000063fce1 in SV_ExecuteClientMessage (cl=0x63300008c820, msg=0x7fffffffba60) at /home/civil/src/OpenJK-civil/code/server/sv_client.cpp:565
#13 0x000000000064d226 in SV_PacketEvent (from=..., msg=<optimized out>) at /home/civil/src/OpenJK-civil/code/server/sv_main.cpp:348
#14 0x00000000005d1f8d in Com_RunAndTimeServerPacket (evFrom=0x7fffffff7540, buf=0x7fffffffba60) at /home/civil/src/OpenJK-civil/code/qcommon/common.cpp:815
#15 0x00000000005d2618 in Com_EventLoop () at /home/civil/src/OpenJK-civil/code/qcommon/common.cpp:854
#16 0x00000000005d4b54 in Com_Frame () at /home/civil/src/OpenJK-civil/code/qcommon/common.cpp:1369
#17 0x0000000000710cbe in main (argc=1, argv=0x7fffffffd838) at /home/civil/src/OpenJK-civil/shared/sys/sys_main.cpp:789
(gdb) frame 0
#0  0x00007fffcfdee148 in PM_AnimLength (index=0, anim=4294967295) at /home/civil/src/OpenJK-civil/code/game/bg_panimate.cpp:4381
4381            return level.knownAnimFileSets[index].animations[anim].numFrames * abs(level.knownAnimFileSets[index].animations[anim].frameLerp);
(gdb) info locals
No locals.
(gdb) info local
No locals.
(gdb) frame 1
#1  0x00007fffcfc23a91 in NPC_ChoosePainAnimation (self=0x7fffd070c0b0 <g_entities+523600>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, damage=9, mod=40, hitLoc=0, 
    voiceEvent=-1) at /home/civil/src/OpenJK-civil/code/game/NPC_reactions.cpp:382
382                     self->painDebounceTime = level.time + PM_AnimLength( self->client->clientInfo.animFileIndex, (animNumber_t) pain_anim );
(gdb) info locals
pain_anim = -1
pain_chance = 0.335714221
(gdb) frame 2
#2  0x00007fffcfc25688 in NPC_Pain (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, damage=9, 
    mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/NPC_reactions.cpp:547
547                             NPC_ChoosePainAnimation( self, other, point, damage, mod, hitLoc, voiceEvent );
(gdb) info local
otherTeam = TEAM_PLAYER
voiceEvent = -1
(gdb) frame 3
#3  0x00007fffcf878129 in NPC_Jedi_Pain (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, other=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, 
    damage=9, mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/AI_Jedi.cpp:6083
6083            NPC_Pain( self, inflictor, other, point, damage, mod );
(gdb) info local
No locals.
(gdb) frame 4
#4  0x00007fffcfa28ed4 in GEntity_PainFunc (self=0x7fffd070c0b0 <g_entities+523600>, inflictor=0x7fffd068c360 <g_entities>, attacker=0x7fffd068c360 <g_entities>, point=0x7fffffff23e0, 
    damage=9, mod=40, hitLoc=0) at /home/civil/src/OpenJK-civil/code/game/g_functions.cpp:355
355             PAINCASE( NPC_Jedi_Pain )
(gdb) info local
No locals.
(gdb) quit
A debugging session is active.

        Inferior 1 [process 17945] will be killed.

Quit anyway? (y or n) y
Civil commented 8 years ago

If I'll add simple check there (if pain_anim is -1 PickAnim from pain1 to pain18), it'll fail in another place:

Program received signal SIGABRT, Aborted.
0x00007ffff66b2528 in raise () from /lib64/libc.so.6
(gdb) backtrace
#0  0x00007ffff66b2528 in raise () from /lib64/libc.so.6
#1  0x00007ffff66b397a in abort () from /lib64/libc.so.6
#2  0x00007ffff66ab417 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff66ab4c2 in __assert_fail () from /lib64/libc.so.6
#4  0x00007fffcfddda1c in AddSightEvent (owner=0x7fffd08b90b0 <g_entities+523600>, position=0x7fffd0889484 <g_entities+327972>, radius=512, alertLevel=AEL_DISCOVERED, addLight=0)
    at /home/civil/src/OpenJK-civil/code/game/NPC_senses.cpp:831
#5  0x00007fffcfc05ab2 in G_CheckSpecialPersistentEvents (ent=0x7fffd0889328 <g_entities+327624>) at /home/civil/src/OpenJK-civil/code/game/g_main.cpp:1036
#6  0x00007fffcfbfa939 in G_RunFrame (levelTime=309000) at /home/civil/src/OpenJK-civil/code/game/g_main.cpp:1977
#7  0x000000000064ee02 in SV_Frame (msec=52, fractionMsec=0) at /home/civil/src/OpenJK-civil/code/server/sv_main.cpp:513
#8  0x00000000005d4d43 in Com_Frame () at /home/civil/src/OpenJK-civil/code/qcommon/common.cpp:1391
#9  0x00000000007570ee in main (argc=1, argv=0x7fffffffd838) at /home/civil/src/OpenJK-civil/shared/sys/sys_main.cpp:789
(gdb) frame 4
#4  0x00007fffcfddda1c in AddSightEvent (owner=0x7fffd08b90b0 <g_entities+523600>, position=0x7fffd0889484 <g_entities+327972>, radius=512, alertLevel=AEL_DISCOVERED, addLight=0)
    at /home/civil/src/OpenJK-civil/code/game/NPC_senses.cpp:831
831             assert( !Q_isnan(position[0]) && !Q_isnan(position[1]) && !Q_isnan(position[2]) );
(gdb) info local
No locals.
(gdb) print position[0]
$1 = 0
(gdb) print position[1]
$2 = 0
(gdb) print position[2]
$3 = -nan(0x7f88f0)
(gdb) frame 5
#5  0x00007fffcfc05ab2 in G_CheckSpecialPersistentEvents (ent=0x7fffd0889328 <g_entities+327624>) at /home/civil/src/OpenJK-civil/code/game/g_main.cpp:1036
1036                                    AddSightEvent( ent->owner, ent->currentOrigin, 512, AEL_DISCOVERED );
(gdb) info local
No locals.
(gdb) print ent->currentOrigin
$4 = {0, 0, -nan(0x7f88f0)}
(gdb) frame 6
#6  0x00007fffcfbfa939 in G_RunFrame (levelTime=309000) at /home/civil/src/OpenJK-civil/code/game/g_main.cpp:1977
1977                    G_CheckSpecialPersistentEvents( ent );
(gdb) info local
i = 219
ent = 0x7fffd0889328 <g_entities+327624>
ents_inuse = 213
(gdb) print ent->currentOrigin
$5 = {0, 0, -nan(0x7f88f0)}
(gdb) q
A debugging session is active.

        Inferior 1 [process 25257] will be killed.

Quit anyway? (y or n) y
ensiform commented 8 years ago

Duplicate bug more or less.

Civil commented 8 years ago

Well, sorry, I haven't found similar bug.

ensiform commented 8 years ago

https://github.com/JACoders/OpenJK/issues?utf8=%E2%9C%93&q=is%3Aissue+animlength

j-horner commented 3 years ago

Fixed in 92059a6b? Same for #698 , #696, #661?

It looks like there's a similiar issue here: https://github.com/JACoders/OpenJK/blob/07675e20746741bc16a712cbf1c9847a5e4a0029/codemp/game/NPC_reactions.c#L366

?

Civil commented 3 years ago

I haven't checked the repo since basically 2016, the hacks I've originally suggested made it stable enough to finish and since then I haven't played it and currently I don't plan to play it again in near future. So I guess it can be closed even if it's not fixed as I won't be able to provide more debug information about the problem.