[CrystalSpace] #982: terrain2 collider tries to call GetHeight() when height data not loaded

"CrystalSpace" <[email protected]> Sun, 30 Jun 2013 18:10:34 -0000
Newsgroups gmane.comp.graphics.crystalspace.tracker
Message-ID <[email protected]>
#982: terrain2 collider tries to call GetHeight() when height data not loaded
---------------------------+------------------------------------------------
 Reporter:  ralphcampbell  |       Owner:  admin
     Type:  defect         |      Status:  new  
 Priority:  major          |   Milestone:       
Component:  libs           |     Version:  V2.1 
 Keywords:                 |  
---------------------------+------------------------------------------------
 I am converting PlaneShift to use the CS threaded loader and hit what
 looks like a bug in terrain2.

 {{{
 Program received signal SIGTRAP, Trace/breakpoint trap.
 0x000000359260eedb in raise (sig=5)
     at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:41
 41                               sig);
 (gdb) bt
 #0  0x000000359260eedb in raise (sig=5)
     at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:41
 #1  0x00007ffff771ed7c in CS::Debug::DebugBreak () at
 ./include/cssysdef.h:971
 #2  0x00007ffff771efec in CS::Debug::AssertMessage (expr=
     0x7fff20c19201 "n < count", filename=
     0x7fff20c191e8 "./include/csutil/array.h", line=702, msg=0x0)
     at /home/ralphc/src/CS_LATEST/libs/csutil/csassert.cpp:82
 #3  0x00007fff20bf3ee0 in csArray<float, csArrayElementHandler<float>,
 CS::Memory::AllocatorMalloc, csArrayCapacityFixedGrow<16> >::Get
 (this=0x7fff2e3bfc38,
     n=19531) at ./include/csutil/array.h:702
 #4  0x00007fff20bf3831 in csArray<float, csArrayElementHandler<float>,
 CS::Memory::AllocatorMalloc, csArrayCapacityFixedGrow<16> >::operator[]
 (this=
     0x7fff2e3bfc38, n=19531) at ./include/csutil/array.h:739
 #5  0x00007fff20bf219f in CS::Plugin::Terrain2::csTerrainCell::GetHeight
 (this=
     0x7fff2e3bfb20, x=256, y=75)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:613
 #6  0x00007fff20bf221b in CS::Plugin::Terrain2::csTerrainCell::GetHeight
 (this=
     0x7fff2e3bfb20, pos=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:623
 #7  0x00007fffea12bc7c in
 CS::Plugin::csOpcode::csTerrainSegmentCellCollider::csTerrainSegmentCellCollider
 (this=0x7fffffffc140, cell=0x7fff2e3bfb38, start=
     ..., end=...)
     at /home/ralphc/src/CS_LATEST/plugins/collide/opcode/segmentcell.h:94
 ---Type <return> to continue, or q <return> to quit---q
 Quit
 (gdb) f 3
 #3  0x00007fff20bf3ee0 in csArray<float, csArrayElementHandler<float>,
 CS::Memory::AllocatorMalloc, csArrayCapacityFixedGrow<16> >::Get
 (this=0x7fff2e3bfc38,
     n=19531) at ./include/csutil/array.h:702
 702         CS_ASSERT (n < count);
 (gdb) p n
 $1 = 19531
 (gdb) p count
 $2 = 0
 (gdb) f 5
 #5  0x00007fff20bf219f in CS::Plugin::Terrain2::csTerrainCell::GetHeight
 (this=
     0x7fff2e3bfb20, x=256, y=75)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:613
 613       return heightmap[y * gridWidth + x];
 (gdb) p gridWidth
 $3 = 257
 (gdb) p loadState
 $4 = iTerrainCell::NotLoaded
 }}}

 I added a check to load the data which seems to fix this problem.

 {{{
 Index: plugins/mesh/terrain/terrain2/cell.cpp
 ===================================================================
 --- plugins/mesh/terrain/terrain2/cell.cpp      (revision 39432)
 +++ plugins/mesh/terrain/terrain2/cell.cpp      (working copy)
 @@ -554,6 +554,7 @@
    if (!collider || !collisionProperties->GetCollidable ())
      return false;

 +  SetLoadState (Loaded);
    return collider->CollideSegment (this, start, end, hitPoint);
  }
 }}}

-- 
Ticket URL: <http://www.crystalspace3d.org/trac/CS/ticket/982>
CrystalSpace <http://www.crystalspace3d.org/>
Free open-source 3D SDK.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev