NaNs

NaNs

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

NaNs

Post by zerver »

FYI, we have some NaNs running around in the code ATM. Seems to be CAirMoveType related. The info I have been able to collect so far is:

Mod: ca-r4610
Unit: armfig
NaN variables: frontdir,rightdir,updir,midpos,speed,pos
The NaNs also propagate to weapons, in this case armfig_freedom_fighter_weapon.

The problem appears as a crash pointing to quadfield.h:
assert(static_cast<unsigned>(i) < baseQuads.size());

It happens when the weapon tries targeting, but the weapon has some NaN member variables.

Trace:

Code: Select all

 	springdev.exe!CQuadField::GetQuad(int i=-2147483648)  Line 58 + 0x33 bytes	C++
 	springdev.exe!CGameHelper::TestTrajectoryAllyCone(const float3 & from={...}, const float3 & flatdir={...}, float length=-1.#IND000, float linear=-1.#IND000, float quadratic=-5.0000002e-005, float spread=0.00000000, float baseSize=3.0000000, int allyteam=0, CUnit * owner=0x1cda9ef0)  Line 1122 + 0x14 bytes	C++
 	springdev.exe!CCannon::TryTarget(const float3 & pos={...}, bool userTarget=true, CUnit * unit=0x1e0f08e0)  Line 142 + 0x70 bytes	C++
 	springdev.exe!CWeapon::AttackUnit(CUnit * unit=0x1e0f08e0, bool userTarget=true)  Line 529 + 0x1b bytes	C++
>	springdev.exe!CUnit::SlowUpdate()  Line 905 + 0x1b bytes	C++
 	springdev.exe!CUnitHandler::Update()  Line 323 + 0x2b bytes	C++
 	springdev.exe!CGame::SimFrame()  Line 3188	C++
 	springdev.exe!CGame::ClientReadNet()  Line 3506	C++
 	springdev.exe!CGame::Update()  Line 2539	C++
 	springdev.exe!SpringApp::Sim()  Line 826 + 0x14 bytes	C++
 	springdev.exe!SpringApp::Simcb(void * c=0x0012fecc)  Line 37 + 0xb bytes	C++
 	springdev.exe!gmlClientServer<void,int,CUnit *>::gmlClientAuxSub()  Line 415 + 0x17 bytes	C++
 	springdev.exe!gmlClientServer<void,int,CUnit *>::gmlClientAux()  Line 428	C++
 	springdev.exe!boost::_mfi::mf0<void,gmlClientServer<void,int,CUnit *> >::operator()(gmlClientServer<void,int,CUnit *> * p=0x032d4500)  Line 49 + 0x12 bytes	C++
 	springdev.exe!boost::_bi::list1<boost::_bi::value<gmlClientServer<void,int,CUnit *> *> >::operator()<boost::_mfi::mf0<void,gmlClientServer<void,int,CUnit *> >,boost::_bi::list0>(boost::_bi::type<void> __formal={...}, boost::_mfi::mf0<void,gmlClientServer<void,int,CUnit *> > & f={...}, boost::_bi::list0 & a={...}, boost::_bi::type<void> __formal={...})  Line 233	C++
 	springdev.exe!boost::_bi::bind_t<void,boost::_mfi::mf0<void,gmlClientServer<void,int,CUnit *> >,boost::_bi::list1<boost::_bi::value<gmlClientServer<void,int,CUnit *> *> > >::operator()()  Line 21	C++
 	springdev.exe!boost::detail::thread_data<boost::_bi::bind_t<void,boost::_mfi::mf0<void,gmlClientServer<void,int,CUnit *> >,boost::_bi::list1<boost::_bi::value<gmlClientServer<void,int,CUnit *> *> > > >::run()  Line 57	C++
 	springdev.exe!boost::`anonymous namespace'::thread_start_function(void * param=0x0017fc00)  Line 167 + 0xd bytes	C++
 	msvcr80d.dll!_callthreadstartex()  Line 348 + 0xf bytes	C
 	msvcr80d.dll!_threadstartex(void * ptd=0x032c7148)  Line 331	C
 	kernel32.dll!77e6482f() 	
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: NaNs

Post by jK »

I had NANs when I tried to compile spring with an outdated GCC, which produced broken SSE code on Athlons.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: NaNs

Post by Kloot »

CAirMoveType has been a (notorious) source of nan's before; I recall removing at least ten of them during the 77b* series. I wouldn't be surprised if there are still some hard-to-reproduce cases left over.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: NaNs

Post by zerver »

I see. What method did you use to track down the root cause of the problem last time?
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: NaNs

Post by zerver »

Never mind - I now have a short replay that reproduces it so should be solved real soon.
Post Reply

Return to “Engine”