invalid FPU flag after boost::asio::ip::address::from_string

invalid FPU flag after boost::asio::ip::address::from_string

Discussion between Spring developers.
Post Reply
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

invalid FPU flag after boost::asio::ip::address::from_string

Post by jK »

During working on the loading stage, I always got this warning:

Code: Select all

[      0] Sync warning: MXCSR 0x1FB6 instead of 0x1D00 or 0x1F80 ("Finalizing")
[      0] Sync warning: FPUCW 0x027F instead of 0x003A or 0x003F ("Finalizing")
I know it isn't that bad when happening during the loading (Spring rechecks the FPU flags during that stage), so I ignored it for some time, also I got those for a very long time for different reasons.
But two days I investigated it further and found out it happens in LuaUI namely in LuaLobby::Connect (I have a demo lualobby widget that gets started during loading). Now this function can get called at any time in the game and Spring won't auto reset the FPU flags after the loading stage, so it can't be ignored anymore.

And here the code that cause these invalid FPU flags, rts/lib/lobby/Connection.cpp:

Code: Select all

void Connection::Connect(...)
{
   ...
   ip::address tempAddr = ip::address::from_string(server, err);
   ...
}
So boost::asio::ip::address::from_string sets invalid FPU flags.

Further checking shows that it is also used in Socket.h
I don't know when the affected function gets called and if it can cause desyncs there, too.

I also tested this on linux and it didn't happened there, so it have to be a problem with the precompiled boost libs in the mingwlibs git repo.


To be on the safe side I will commit a patch to reset the FPU state in LuaLobby, still I don't know what to do with Socket.h.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: invalid FPU flag after boost::asio::ip::address::from_string

Post by Tobi »

Even in game the flags are reset right after the warning happens. Usually this doesn't help though as often the problem is recurring.

The problem doesn't necessarily lie in boost btw, could also be in the underlying windows library / libraries.

Anyway, resetting (using `streflop_init<streflop::Simple>();') right after the the offending command is a decent solution IMO, I used that too after creating a new thread for the game server, there a similar thing happened.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: invalid FPU flag after boost::asio::ip::address::from_string

Post by hoijui »

am using that in the Java AI Interface too, after every call to the JVM. what is the problem with Socket.h, why could you not use the same thing there?

(btw, your changes broke spring-headless)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: invalid FPU flag after boost::asio::ip::address::from_string

Post by jK »

Tobi wrote:Even in game the flags are reset right after the warning happens. Usually this doesn't help though as often the problem is recurring.
Ahh nice, good_fpu_control_registers() gets called before each simframe (even when it's too late it still informs you).
Tobi wrote:The problem doesn't necessarily lie in boost btw, could also be in the underlying windows library / libraries.
Hmmm, yeah sounds reasonable. So I will add the FPU reset in Socket.h too and add a comment.
Tobi wrote:Anyway, resetting (using `streflop_init<streflop::Simple>();') right after the the offending command is a decent solution IMO, I used that too after creating a new thread for the game server, there a similar thing happened.
Yeah, I know that, or better I know that since I tried to make a new thread sync safe (needed for my loadingscreen stage changes).
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: invalid FPU flag after boost::asio::ip::address::from_string

Post by jK »

hoijui wrote:(btw, your changes broke spring-headless)
It's the linux build that's broken. I wrote X11 code in SpringApp.cpp and then wanted to separate it into a new file, but it seems one of SpringApp dependencies included a header the X11 code needs and google didn't helped me to find the headers I need to include.
Post Reply

Return to “Dedicated Developer Discussion”