Aloush154 / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

Convex-convex Collision Crash #657

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create convexhullshape and trimeshshape objects
2. Make trimeshshape object as static and make convexhull to fall from a height

What is the expected output? What do you see instead?
Expecting the collision to happen normal, but the app crashes when the objects 
collide each other or with trimesh shape. 

What version of the product are you using? On what operating system?
2.81

Please provide any additional information below.

xxxx.exe!_maxdot_large()  + 0x2e2 bytes C++
xxxx.exe!btConvexShape::project()  + 0x318 bytes    C++
xxxx.exe!btConvexShape::localGetSupportVertexWithoutMarginNonVirtual()  + 0x45a 
bytes   C++
xxxx.exe!btGjkPairDetector::getClosestPointsNonVirtual()  + 0x32f bytes C++
xxxx.exe!btGjkPairDetector::getClosestPoints()  + 0x14 bytes    C++
xxxx.exe!ProcessSpuConvexConvexCollision()  + 0x515 bytes   C++
xxxx.exe!handleCollisionPair()  + 0x13b bytes   C++
xxxx.exe!processCollisionTask()  + 0x78d bytes  C++

Original issue reported on code.google.com by nharisha...@gmail.com on 9 Oct 2012 at 7:40

GoogleCodeExporter commented 8 years ago
This problem happens only with MultiThreaded setup. 

Original comment by nharisha...@gmail.com on 9 Oct 2012 at 7:42

GoogleCodeExporter commented 8 years ago
Can you re-create the problem in a modified Bullet demo and attach it to this 
issue?

Thanks a lot,
Erwin

Original comment by erwin.coumans on 9 Oct 2012 at 3:54

GoogleCodeExporter commented 8 years ago
I have seen this issue before, this was due to 
badly generated convex hulls in our case, from single triangle meshes
or completly flat meshes.

Original comment by majestik...@gmail.com on 10 Oct 2012 at 2:57

GoogleCodeExporter commented 8 years ago
We used v2.80 and it was working fine so far. Once we replaced the sources with 
2.81, we had this issue. 
I'll try to make a standalone example to reproduce this problem.

Original comment by nharisha...@gmail.com on 10 Oct 2012 at 3:12

GoogleCodeExporter commented 8 years ago
The _maxdot_large is a new SIMD optimized routine (contributed by Apple)

It requires the data to be 16-byte aligned. There might be some limitations of 
the routine that I'm not aware of yet. How many vertices does your convex have?

Can you provide more information about the line number/location of the crash, 
in debug mode?

Original comment by erwin.coumans on 10 Oct 2012 at 3:34

GoogleCodeExporter commented 8 years ago
Looking at the code, it might be that for a concave trimesh, the vertices are 
not 16-byte aligned, causing the crash.

If it is a showstopper, you can always disable the SIMD optimization

in LinearMath/btVector3.h check out btVector3::maxDot and change the line

 if( array_count < scalar_cutoff )
into
if (1)

Still, we should fix it so I hope for an easy reproduction case.

Original comment by erwin.coumans on 10 Oct 2012 at 3:44

GoogleCodeExporter commented 8 years ago
One more possibility for unaligned data:

can you change
class spuNodeCallback : public btNodeOverlapCallback
into
ATTRIBUTE_ALIGNED16(class) spuNodeCallback : public btNodeOverlapCallback

in file 
bullet\src\BulletMultiThreaded\SpuNarrowPhaseCollisionTask\SpuGatheringCollision
Task.cpp around line 294 and see if that helps?

Original comment by erwin.coumans on 10 Oct 2012 at 3:53

GoogleCodeExporter commented 8 years ago
@Erwin

The last suggestions fixed the problem. The first suggestion didn't help. I'll 
try to test it in few more levels today to confirm this fix. :)

Thanks a lot.

Original comment by nharisha...@gmail.com on 10 Oct 2012 at 4:05

GoogleCodeExporter commented 8 years ago
Thanks for the feedback!

I'm baffled that the first suggestions didn't help, changing the line
 if( array_count < scalar_cutoff )
into
if (1)
because in that case the _maxdot_large method should not be called.

Original comment by erwin.coumans on 10 Oct 2012 at 4:17

GoogleCodeExporter commented 8 years ago
I am wondering if this is the line producing the problem.
https://code.google.com/p/bullet/source/browse/trunk/src/LinearMath/btVector3.h#
994

Original comment by nharisha...@gmail.com on 10 Oct 2012 at 4:40

GoogleCodeExporter commented 8 years ago
Ah, indeed. In case the data is not aligned, you need to disable both _maxdot 
and _mindot.

I checked in the ATTRIBUTE_ALIGNED16 fix, can you let me know if you see any 
other crashes?

Original comment by erwin.coumans on 10 Oct 2012 at 4:42

GoogleCodeExporter commented 8 years ago
I tried running the fixed code on different ConvexHull and TriMesh Combinations 
and there was no crashes so far. I'll try MacOSX and IOS port of the same and 
let you know later today.

Original comment by nharisha...@gmail.com on 10 Oct 2012 at 4:47

GoogleCodeExporter commented 8 years ago
On the same Win32 project after I rebuilt all projects, I still have the same 
crash, when objects collide. The ATTRIBUTE_ALIGNED16 fix didn't help. 

I just run the code in debug mode:

.exe!_maxdot_large(const float * vv, const float * vec, unsigned long count, 
float * dotResult)  Line 187    C++
.exe!convexHullSupport(const btVector3 & localDirOrg, const btVector3 * points, 
int numPoints, const btVector3 & localScaling)  Line 113 + 0x12d bytes  C++
.exe!btConvexShape::localGetSupportVertexWithoutMarginNonVirtual(const 
btVector3 & localDir)  Line 276 + 0x1d bytes    C++
.exe!btGjkPairDetector::getClosestPointsNonVirtual(const 
btDiscreteCollisionDetectorInterface::ClosestPointInput & input, 
btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * 
debugDraw)  Line 147    C++
.exe!btGjkPairDetector::getClosestPoints(const 
btDiscreteCollisionDetectorInterface::ClosestPointInput & input, 
btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * 
debugDraw, bool swapResults)  Line 77   C++
.exe!ProcessSpuConvexConvexCollision(SpuCollisionPairInput * wuInput, 
CollisionTask_LocalStoreMemory * lsMemPtr, SpuContactResult & spuContacts)  
Line 781    C++
.exe!handleCollisionPair(SpuCollisionPairInput & collisionPairInput, 
CollisionTask_LocalStoreMemory & lsMem, SpuContactResult & spuContacts, 
unsigned int collisionShape0Ptr, void * collisionShape0Loc, unsigned int 
collisionShape1Ptr, void * collisionShape1Loc, bool dmaShapes)  Line 861    C++
.exe!processCollisionTask(void * userPtr, void * lsMemPtr)  Line 1385 + 0x32 
bytes   C++
.exe!Thread_no_1(void * lpParam)  Line 67   C++

Original comment by nharisha...@gmail.com on 10 Oct 2012 at 5:29

GoogleCodeExporter commented 8 years ago
I reproduced it using the multi-threaded benchmark, and fixed it in latest 
trunk:
https://code.google.com/p/bullet/source/detail?r=2616

thanks for the report!

Original comment by erwin.coumans on 10 Oct 2012 at 6:36

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I  have similar problem in 2.8.1

when I run ios demo, err: undefined symbol. _maxdot_large  && _mindot_large

After My search. I solved This problem.

Checking LinearMath--> btVector3.cpp 

line 42&43

long _maxdot_large( const float *vv, const float *vec, unsigned long count, 
float *dotResult );
long _maxdot_large( const float *vv, const float *vec, unsigned long count, 
float *dotResult )

I found function declare at cpp.
I just move declare to  .h file.
And everything goes right.

Hopes can help.

Original comment by dinosaur...@gmail.com on 30 Sep 2013 at 2:34