pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.62k stars 374 forks source link

Floating point arithmetic exception on ShipAICmd.cpp #4288

Open CampNowhere opened 6 years ago

CampNowhere commented 6 years ago

To replicate: Go to star system referenced in the attached file. Target the first planet orbiting the black hole (BH1b1), hit autopilot, and "enter low orbit around BH1b1".

I re-implemented the std::max function locally to make debugging easier, but the same exception happens with current master (4d32739b69). It looks like there's a max operation being done on the xmm1 and xmm2 registers being done before returning, for some reason. I'm not sure why this is happening. The greater than comparison is being done in the ucomisd instruction a couple of lines above. And nonsense data (0x800000....) seems to be loaded into xmm1.

I'll work on this further, I just wanted to put it out there for everyone else to look at.

crash

07_bh1.txt

jaj22 commented 6 years ago

The black hole is coming out of the sysgen with zero radius. The terrain code has no idea what to do with a zero-radius body, so the terrain feature height comes out as a NaN which is passed through to the black hole's m_physradius. This throws an exception in the autopilot, because we enable exceptions around it.

I don't know what physical radius black holes are supposed to have. Maybe the event horizon?

impaktor commented 6 years ago

I don't know what physical radius black holes are supposed to have. Maybe the event horizon?

Sounds reasonable. So what would the best fix be for this issue? Why does the black hole have zero radius? It doesn't in the lua-file, as far as I can see.

richardpl commented 6 years ago

Lua file doesn't set radius of black hole, so it defaults to 0 for some reason.

mike-f1 commented 5 years ago

So what would the best fix be for this issue?

Correct system generation code to force radius (or the default) to be more than Schwarzschild radius?