View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001625 | Spring engine | General | public | 2009-09-05 08:46 | 2009-10-03 10:46 |
| Reporter | hughperkins | Assigned To | hoijui | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Target Version | 0.81.0.0 | Fixed in Version | 0.80.4.0+git | ||
| Summary | 0001625: Java interface v0.1: CreateLineFigureDrawerAICommand causes Spring to segfault | ||||
| Description | Java interface v0.1: CreateLineFigureDrawerAICommand causes Spring to segfault To reproduce, run the following function in a Java AI, using Java Interface v0.1 // This will crash spring, at least with Java interface 0.1, // running against Spring 0.80.02 : void drawlineTests2() { CSAI csai = playerObjects.getCSAI(); csai.handleEngineCommand( new CreateLineFigureDrawerAICommand( new AIFloat3( 0,100,0 ), new AIFloat3( 100, 100 , 0 ), 1, false, 200, 0, 0 ) ); } | ||||
| Additional Information | tested with Spring 0.80.02, Java interface v0.1 | ||||
| Tags | No tags attached. | ||||
| Attached Files | |||||
| Checked infolog.txt for Errors | |||||
|
|
it segfaults in float fastmath::sqrt_sse(float x), at rts/System/FastMath.h:68 i attached a file with GDB output of the crash, with the intersting part beeing this (use git master commit 096cb26fede865aecb5798a0f1b452d50e373490 as reference): [code] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb640f710 (LWP 18372)] fastmath::sqrt_sse (x=10000) at rts/System/FastMath.h:68 (gdb) bt #0 fastmath::sqrt_sse (x=10000) at rts/System/FastMath.h:68 #1 0x082ee033 in math::sqrt (x=10000) at rts/System/FastMath.h:264 #2 0x082ee0ea in float3::distance (this=0xbff8c658, f=@0xbff8c64c) at rts/System/float3.h:386 0000003 0x087b7b22 in CGeoSquareProjectile (this=0xc690540, p1=@0xbff8c658, p2=@0xbff8c64c, v1=@0xbff8c5dc, v2=@0xbff8c5dc, w1=0.5, w2=0.5) at rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.cpp:41 0000004 0x086c6b65 in CGeometricObjects::AddLine (this=0xb667628, start={static binder = {class_ = 0x9fc3618, base = 0x0, flags = creg::CF_None, memberRegistrator = 0x8bbc344, name = 0x8a5990c "float3", size = 12, constructor = 0x88a59a6 <float3::_ConstructInstance(void*)>, destructor = 0x88a59d6 <float3::_DestructInstance(void*)>, nextBinder = 0x8bbc320}, static memberRegistrator = 0x8bbc3b4, static CMP_EPS = 9.99999975e-05, static NORMALIZE_EPS = 9.99999996e-13, static maxxpos = 4095, static maxzpos = 4095, x = -1.94355297, y = -1.94355154, z = 1}, end={static binder = {class_ = 0x9fc3618, base = 0x0, flags = creg::CF_None, memberRegistrator = 0x8bbc344, name = 0x8a5990c "float3", size = 12, constructor = 0x88a59a6 <float3::_ConstructInstance(void*)>, destructor = 0x88a59d6 <float3::_DestructInstance(void*)>, nextBinder = 0x8bbc320}, static memberRegistrator = 0x8bbc3b4, static CMP_EPS = 9.99999975e-05, static NORMALIZE_EPS = 9.99999996e-13, static maxxpos = 4095, static maxzpos = 4095, x = -1.94355154, y = 1, z = 0}, width=1, arrow=0, lifetime=200, group=1) at rts/Sim/Misc/GeometricObjects.cpp:120 0000005 0x089b949e in CAICallback::CreateLineFigure (this=0xa9cd0e8, pos1={static binder = {class_ = 0x9fc3618, base = 0x0, flags = creg::CF_None, memberRegistrator = 0x8bbc344, name = 0x8a5990c "float3", size = 12, constructor = 0x88a59a6 <float3::_ConstructInstance(void*)>, destructor = 0x88a59d6 <float3::_DestructInstance(void*)>, nextBinder = 0x8bbc320}, static memberRegistrator = 0x8bbc3b4, static CMP_EPS = 9.99999975e-05, static NORMALIZE_EPS = 9.99999996e-13, static maxxpos = 4095, static maxzpos = 4095, x = -1.94358444, y = -1.94358301, z = 1}, pos2={static binder = {class_ = 0x9fc3618, base = 0x0, flags = creg::CF_None, memberRegistrator = 0x8bbc344, name = 0x8a5990c "float3", size = 12, constructor = 0x88a59a6 <float3::_ConstructInstance(void*)>, destructor = 0x88a59d6 <float3::_DestructInstance(void*)>, nextBinder = 0x8bbc320}, static memberRegistrator = 0x8bbc3b4, static CMP_EPS = 9.99999975e-05, static NORMALIZE_EPS = 9.99999996e-13, static maxxpos = 4095, static maxzpos = 4095, x = -1.94358301, y = 1, z = 0}, width=1, arrow=0, lifetime=200, group=0) at rts/ExternalAI/AICallback.cpp:1026 #6 0x089aed5e in skirmishAiCallback_Engine_handleCommand (teamId=1, toId=-1, commandId=-1, commandTopic=32, commandData=0xc5faff8) at rts/ExternalAI/SSkirmishAICallbackImpl.cpp:522 [/code] |
|
|
i did the same test with NullLegacyCppAI, and it does not segfault there. So it is either the native part of the Java Interface somehow messing up something about SSE (baczek said it could be data alignment), or it is the JVM messing up the environment, eg. FPU/CPU state. |
|
|
did some testing: JDKs tested: 1.6.0_12, 1.6.0_16, 1.7.0m4 JVM flags: -XX:UseSSE=0 -XX:UseSSE=1 -XX:+RestoreMXCSROnJNICalls -Xint -XX:+AlwaysRestoreFPU -XX:+CITime -XX:+CheckJNICalls -Xcheck:jni -verbose:jni -XX:+UnlockDiagnosticVMOptions (tried various combinations of these.. they do not help) also resetted the FPU with streflop before the relevant code, same outcome. i need help! |
|
|
a LOT of investigating, fetching tips from 3 different IRC channels and many hours later: results of the jurney can be seen here: http://springrts.com/phpbb/viewtopic.php?f=12&t=20408 in short: the JVM seems to mess up memory alignment (SSE functions need 16bit alignment). There is an attribute that forces aligment in a fucntion, which fixes this bug, but it first has to be aproved to not hurt performance too much. From how it looks to me, chances are good that it will be applied. (it even looks as if i accidentially came up with a way to speed up SSE sqrt() by up to 30% ;-) ) |
|
|
fixed with git commit: 166a8cf8cb7f681f85e601b742e176da56cc394c with spring default flags, the performance los is hardly there, and as i accidentially came up with a 25% - 50% speed up of sqrt by the way, it was no question whether ot incliude it or not :D for more details, see: http://springrts.com/phpbb/viewtopic.php?f=12&t=20408 |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2009-09-05 08:46 | hughperkins | New Issue | |
| 2009-09-11 12:48 | hoijui | Relationship added | related to 0001634 |
| 2009-09-11 13:29 | hoijui | Relationship deleted | related to 0001634 |
| 2009-09-11 13:31 | hoijui | File Added: GDB_output_096cb26fede865aecb5798a0f1b452d50e373490.txt | |
| 2009-09-11 13:39 | hoijui | Note Added: 0004103 | |
| 2009-09-11 13:59 | hoijui | Project | AI => Spring engine |
| 2009-09-11 17:06 | hoijui | Note Added: 0004107 | |
| 2009-09-12 14:03 | hoijui | Note Added: 0004112 | |
| 2009-09-18 12:04 | hoijui | Note Added: 0004144 | |
| 2009-09-18 22:55 | hoijui | Note Added: 0004153 | |
| 2009-09-18 22:55 | hoijui | Status | new => resolved |
| 2009-09-18 22:55 | hoijui | Fixed in Version | => 0.80.4.0+git |
| 2009-09-18 22:55 | hoijui | Resolution | open => fixed |
| 2009-09-18 22:55 | hoijui | Assigned To | => hoijui |
| 2009-10-03 10:46 | imbaczek | Target Version | => 0.81.0.0 |