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.01k stars 612 forks source link

R_FogFactor crash #450

Closed Razish closed 10 years ago

Razish commented 10 years ago

Linux 64-bit on any map with fog, usually after a few seconds of gameplay. Reproduced on mp/ffa1 at jawa.jk3.in:29070

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff56abf2a in R_FogFactor (s=-nan(0x400000), t=-nan(0x400000)) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_image.cpp:1217
1217        d = tr.fogTable[ (int)(s * (FOG_TABLE_SIZE-1)) ];
(gdb) bt
#0  0x00007ffff56abf2a in R_FogFactor (s=-nan(0x400000), t=-nan(0x400000)) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_image.cpp:1217
#1  0x00007ffff56c91f2 in RB_CalcModulateColorsByFog (
    colors=0x7ffff5b833e0 <tess+108000> '\377' <repeats 49 times>, "\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377\377\020\377\377"...) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade_calc.cpp:772
#2  0x00007ffff56c5adc in ComputeColors (pStage=0x425bf20, forceRGBGen=6) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1372
#3  0x00007ffff56c686d in RB_IterateStagesGeneric (input=0x7ffff5b68e00 <tess>) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1655
#4  0x00007ffff56c6d4a in RB_StageIteratorGeneric () at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1828
#5  0x00007ffff56c71bf in RB_EndSurface () at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1959
#6  0x00007ffff568bfa0 in RB_RenderDrawSurfList (drawSurfs=0x400bff0, numDrawSurfs=668) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:819
#7  0x00007ffff568d9bd in RB_DrawSurfs (data=0x41b0178) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:1510
#8  0x00007ffff568e3c7 in RB_ExecuteRenderCommands (data=0x41b0178) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:1809
#9  0x00007ffff5696fdd in R_IssueRenderCommands (runPerformanceCounters=qtrue) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_cmds.cpp:86
#10 0x00007ffff5697811 in RE_EndFrame (frontEndMsec=0x0, backEndMsec=0x0) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_cmds.cpp:426
#11 0x00000000004cf397 in SCR_UpdateScreen () at /home/tex/projects/OpenJK/codemp/client/cl_scrn.cpp:506
#12 0x00000000004c845a in CL_Frame (msec=16) at /home/tex/projects/OpenJK/codemp/client/cl_main.cpp:2186
#13 0x0000000000426ca5 in Com_Frame () at /home/tex/projects/OpenJK/codemp/qcommon/common.cpp:1591
#14 0x0000000000522d55 in main (argc=9, argv=0x7fffffffe1e8) at /home/tex/projects/OpenJK/codemp/sys/sys_main.cpp:620
ensiform commented 10 years ago

The problem is that the tex coords are being trashed in RB_CalcFogTexCoords it seems (or) its trying to access texcoords that are not valid as it is.

xycaleth commented 10 years ago

Happens with OS X as well, when launching the game using the binary (not the app bundle).

xycaleth commented 10 years ago

Just to keep updating this as I dig into the code, the contents of tess.xyz seem to be getting munged (they contain NaNs) by the time RB_CalcFogTexCoords tries to access them.

I've looked into this further. tess.fogNum is being assigned a value greater than the number of loaded fogs, in RB_BeginSurface.

Razish commented 10 years ago

I'm still getting this issue, currently replicating it on mp/ctf4, usually within a few seconds of joining the game, maybe 15 at max, usually instantly. Linux x86_64, debug build of OpenJK from latest git

tex@textop ~/ja % gdb openjk.x86_64
(gdb) run +set fs_game "japlus" +set sv_pure "0" +map mp/ctf4
(debug)OpenJK-MP: v1.0.1.0 linux-x86_64-debug Dec 31 2013

]team r
Raz0r entered the game

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff56aac68 in R_FogFactor (s=-nan(0x400000), t=0.96875) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_image.cpp:1217
1217        d = tr.fogTable[ (int)(s * (FOG_TABLE_SIZE-1)) ];
(gdb) backtrace
#0  0x00007ffff56aac68 in R_FogFactor (s=-nan(0x400000), t=0.96875) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_image.cpp:1217
#1  0x00007ffff56c7252 in RB_CalcModulateColorsByFog (colors=0x7ffff5b81420 <tess+108000> "\177") at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade_calc.cpp:772
#2  0x00007ffff56c3b3c in ComputeColors (pStage=0x5c4b6d0, forceRGBGen=6) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1372
#3  0x00007ffff56c48cd in RB_IterateStagesGeneric (input=0x7ffff5b66e40 <tess>) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1655
#4  0x00007ffff56c4daa in RB_StageIteratorGeneric () at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1828
#5  0x00007ffff56c521f in RB_EndSurface () at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_shade.cpp:1959
#6  0x00007ffff568a000 in RB_RenderDrawSurfList (drawSurfs=0x5895480, numDrawSurfs=445) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:819
#7  0x00007ffff568ba1d in RB_DrawSurfs (data=0x5a39608) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:1510
#8  0x00007ffff568c427 in RB_ExecuteRenderCommands (data=0x5a39608) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_backend.cpp:1809
#9  0x00007ffff569503d in R_IssueRenderCommands (runPerformanceCounters=qtrue) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_cmds.cpp:86
#10 0x00007ffff5695871 in RE_EndFrame (frontEndMsec=0x0, backEndMsec=0x0) at /home/tex/projects/OpenJK/codemp/rd-vanilla/tr_cmds.cpp:426
#11 0x00000000004cf6ed in SCR_UpdateScreen () at /home/tex/projects/OpenJK/codemp/client/cl_scrn.cpp:506
#12 0x00000000004c87b0 in CL_Frame (msec=16) at /home/tex/projects/OpenJK/codemp/client/cl_main.cpp:2186
#13 0x0000000000426ca5 in Com_Frame () at /home/tex/projects/OpenJK/codemp/qcommon/common.cpp:1591
#14 0x00000000005230ab in main (argc=12, argv=0x7fffffffe208) at /home/tex/projects/OpenJK/codemp/sys/sys_main.cpp:620
ensiform commented 10 years ago

You sure you're actually up to date :|

Razish commented 10 years ago

Absolutely. Deleted all binaries, cleaned build files, pulled from git, regenerated makefile, built project. Multiple times to make absolute sure.

(debug)OpenJK-MP: v1.0.1.0 linux-x86_64-debug Dec 31 2013
xycaleth commented 10 years ago

Baw, I'll take another look in a few hours.

xycaleth commented 10 years ago

@Razish Quick run through now doesn't give me any crashes on ctf4.

xycaleth commented 10 years ago

I can't reproduce this bug in my VM which is running Ubuntu 13.10 64-bit. Testing with a debug build.

xycaleth commented 10 years ago

This bug reappears when using JA++. The problem comes from the SFX sabers, which at some point give some NaNs to the engine.

I'll need to rethink my fix to handle NaNs more gracefully, as crashing isn't ever a good thing outside of debugging.

xycaleth commented 10 years ago

Confirmed to be fixed now for JA++.