Possible Memory Bug in btDbvt.cpp

AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Possible Memory Bug in btDbvt.cpp

Post by AshMcConnell »

Hi Folks,

I have been experimenting with Intel's Inspector tool (30 day trial) which can detect memory issues such as Uninitialized Memory. I have found quite a few potential problems in my code, but I've noticed one in bullet too. It could be nothing, but I thought I should report it in any case. I don't know the source very well, so hopefully someone can figure out if it could be a problem.

The memory is allocated in insertLeaf / createnode: -

Code: Select all

btDbvtNode*    prev=root->parent;
btDbvtNode*    node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
It is reporting that uninitialized memory is being accessed on line 193 here: -

Code: Select all

191	            while(prev)
192	            {
193	                const btDbvtVolume    pb=prev->volume;
194	                Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
195	                if(NotEqual(pb,prev->volume))
196	                {
197	                    prev=prev->parent;
198	                } else break;
199	            }
So I assume its the volume that hasn't been initialized. Which could cause a problem for the Merge and NotEqual functions?

Hope this helps!
All the best,
Ash
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Possible Memory Bug in btDbvt.cpp

Post by Erwin Coumans »

It needs to be reviewed indeed, I create an issue for it here:

http://code.google.com/p/bullet/issues/detail?id=463

Thanks for the report!
Erwin
liangma
Posts: 4
Joined: Wed Feb 18, 2009 6:33 pm

Re: Possible Memory Bug in btDbvt.cpp

Post by liangma »

AshMcConnell wrote:Hi Folks,

I have been experimenting with Intel's Inspector tool (30 day trial) which can detect memory issues such as Uninitialized Memory. I have found quite a few potential problems in my code, but I've noticed one in bullet too. It could be nothing, but I thought I should report it in any case. I don't know the source very well, so hopefully someone can figure out if it could be a problem.

The memory is allocated in insertLeaf / createnode: -

Code: Select all

btDbvtNode*    prev=root->parent;
btDbvtNode*    node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
It is reporting that uninitialized memory is being accessed on line 193 here: -

Code: Select all

191	            while(prev)
192	            {
193	                const btDbvtVolume    pb=prev->volume;
194	                Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
195	                if(NotEqual(pb,prev->volume))
196	                {
197	                    prev=prev->parent;
198	                } else break;
199	            }
So I assume its the volume that hasn't been initialized. Which could cause a problem for the Merge and NotEqual functions?

Hope this helps!
All the best,
Ash

that's a loop to remove leaf node and rebuild the tree.
I think prev may point to invalid memory in some special case.
prev point to parent's parents, only root's parents is null. ............
need more context for test case