2025-07-04 15:50 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000686Spring engineGeneralpublic2010-07-07 09:57
Reporterredstar 
Assigned TojK 
PrioritynormalSeveritycrashReproducibilityhave not tried
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000686: Ground Tearing and a Game Crash
DescriptionI noticed on comet catcher that soemtimes there ws a tear in the ground between 2 sections, which showed up depending on the terrain view radius and the angle of viewing.

While trying to examine the error a crash occurred.

An image of the glitch and a screenshot of VS2005 debugger in the crash are attatched.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0001447

tvo (reporter)

Out of bounds heightData array access, no clue why. Here is the math:

CC is 12 x 16, meaning 769 x 1025 = 788225 heightmap size

line 372 more readable is:

float h =
    ( heightData[(y)*heightDataX+x+lod]
    + heightData[(y+lod*2)*heightDataX+x+lod])*0.5f*(1-camxpart)
    + heightData[(y+lod)*heightDataX+x+lod]*(camxpart);

so the array element that would be the first to be accessed out of range is
heightData[(y+lod*2)*heightDataX+x+lod]

y = 0, lod = 512, heightDataX = 769, x = 512, so the array index is: 788480
788480 > 788225 --> out of bounds array access

~0001449

tvo (reporter)

Last edited: 2007-11-19 12:09

For anyone picking this up, here is some code snippet that may help debugging it:

struct HeightDataCheck {
    int size;
    float* heightData;
    HeightDataCheck(float* h) : size((gs->mapx+1)*(gs->mapy+1)), heightData(h) { }
    int operator[] (int i) const {
        if (i >= size)
            __asm {
                int 3
            };
        return heightData[i];
    }
} heightData(this->heightData);

Add this to the start of CBFGroundDrawer::Draw (MSVC only) and you have a fast (and actually working) conditional breakpoint on all out of bounds heightData array access (works by shadowing the heightData member with a local HeightDataCheck variable.)

Personally I still don't know why it happens, debugging 450 line functions isn't particularly easy :-)

Either way, reproducing is easy:
- Add the above debugging code to BFGroundDrawer.cpp & compile
- Start spring with Comet Catcher Remake
- Set viewRadius to 4 (/decreaseviewradius)
- Move camera to lower left corner of map.
- Press tab.
- Conditional breakpoint triggers => good luck debugging :-)

EDIT: ok, not that easy, it doesn't seem 100% deterministic, but using shift+tab instead of tab (faster zoom out) seems to work pretty often too.

~0005072

jK (developer)

happened cause of too low terrain detail
+Notes

-Issue History
Date Modified Username Field Change
2007-11-18 00:48 redstar New Issue
2007-11-18 00:48 redstar File Added: ground_tears.jpg
2007-11-18 00:49 redstar File Added: crash.png
2007-11-19 00:40 tvo Note Added: 0001447
2007-11-19 12:02 tvo Note Added: 0001449
2007-11-19 12:09 tvo Note Edited: 0001449
2010-07-07 09:57 jK Note Added: 0005072
2010-07-07 09:57 jK Status new => resolved
2010-07-07 09:57 jK Resolution open => fixed
2010-07-07 09:57 jK Assigned To => jK
+Issue History