ryzom / ryzomcore

Ryzom Core is the open-source project related to the Ryzom game. This community repository is synchronized with the Ryzom Forge repository, based on the Core branch.
https://wiki.ryzom.dev
GNU Affero General Public License v3.0
331 stars 89 forks source link

server crash when compiled with -O3 switch #97

Closed ryzom-pipeline closed 10 years ago

ryzom-pipeline commented 10 years ago

Original report by Meelis Mägi (Bitbucket: [Meelis Mägi](https://bitbucket.org/Meelis Mägi), ).


It seems that with -O3 switch, compiler will remove some required code making IOS to crash when receiving NPC talk message

I added some debug messages and got this in log

#!

compiled with -O3
send_chat.h 91 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54 )
send_chat.h 92 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54  4  0  0  2 )
send_chat.h 93 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54  4  0  0  2 )
send_chat.h 94 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54  4  0  0  2  8  0  0  0 43 48 49 41 4E 47 5F 32 )

compiled with -O2
send_chat.h 91 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54 )
send_chat.h 92 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54 34 75  0  2 )
send_chat.h 93 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54 34 75  0  2  1  0  0  0 )
send_chat.h 94 npcChatToChannel : (('NPC_CHAT') 7B  0  0  0  1  8  0  0  0 4E 50 43 5F 43 48 41 54 34 75  0  2  1  0  0  0  8  0  0  0 43 48 49 41 4E 47 5F 32 )

Compiler is gcc 4.6.3-1ubuntu5

As you can see, send_chat.h line 93 does not add anything to output buffer when compiled with -O3 and making message too short for IOS to read.

ryzom-pipeline commented 10 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I already noticed some problems with -O3 under Android, but it was a GCC crash while compiling. Please do you know if it's a known GCC bug fixed in more recent versions ?

It could be really problematic indeed :(

ryzom-pipeline commented 10 years ago

Original comment by Meelis Mägi (Bitbucket: [Meelis Mägi](https://bitbucket.org/Meelis Mägi), ).


gcc-4.8.1-10ubuntu9 (saucy) and compiled with -O3, multiple services are chain crashing on startup.

When compiled with -O2, everything seems to be fine.

ryzom-pipeline commented 10 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


Thanks for the investigation !

ryzom-pipeline commented 10 years ago

Original comment by Matt Raykowski (Bitbucket: [Matt Raykowski](https://bitbucket.org/Matt Raykowski), ).


-O3 optimization has been a problem for many years. I have no idea why, Nevrax just forced -O2 or lower.

ryzom-pipeline commented 10 years ago

Original comment by Matthew Lagoe (Bitbucket: botanic, GitHub: botanic).


The diference between 02 and 03 are

-fgcse-after-reload -finline-functions -fipa-cp-clone -fpredictive-commoning -ftree-loop-distribute-patterns -ftree-vectorize -funswitch-loops

I would say compile it with -O2 and then add one of the above flags till it doesnt work. Will at least tell us what flag is causing it to crash, that said i would guess its -ftree-vectorise

ryzom-pipeline commented 10 years ago

Original comment by Meelis Mägi (Bitbucket: [Meelis Mägi](https://bitbucket.org/Meelis Mägi), ).


gcc-4.6 (ubuntu precise)

gcc-4.8 (ubuntu saucy)

ryzom-pipeline commented 10 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Committed a patch that seems to work for me, please check if this resolves the issue.

ryzom-pipeline commented 10 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


If possible, can someone make the compiler output which functions declared as inline are not inlined under -O2

ryzom-pipeline commented 10 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


This should be fixed now.