Software Archive
Read-only legacy content
17061 Discussions

False Positives when Boost::shared_ptr is used with Inspector?

Ash_McConnell
Beginner
537 Views
Hi Folks,

I've downloaded the 30 day trial for Parallel Studio. It has helped me find a few bugs, but when I started to analyse stack accesses it seems to have produced a lot of false positives. Here is an example

[cpp]void DriveTrain::finalise()
{
    _engine->finalise();
    _driveShaftHinge->FixLinkParams();
    _gearBox->FixLinkParams();
    _diff->FixLinkParams();
}

[/cpp]
It has reported an "Uninitialized Memory Access" on the last line (_diff->FixLinkParams()). _diff is created in the constructor, it is a boost::shared_ptr
[cpp]int PhyConstraint::FixLinkParams()
{
	gunsigned i;
	for(i=0;i==NULL) return 1;
	}
	
	return 0;
}[/cpp]
In the FixLinkParams method I'm sure that NRigidBody and ppRigidBody are initialised.

Am I missing something or is there a problem here?

Thanks for your help
All the best,
Ash
0 Kudos
4 Replies
Matthew_F_Intel
Employee
537 Views
Hi Ash-
Is Parallel Inspector reporting the problem as being inside the function FixLinkParams() or at the point when you are dereferencing _diff (line 6. of finalise()?) And is any of _diff or that which _diff points to allocated on the stack? (For anything not on the stack the "uninitialized memory access" diagnostic should be giving you the code location where the object was allocated.)
-Matt
0 Kudos
Ash_McConnell
Beginner
537 Views
Hi Matt,
Thanks for the reply,

It is at the point of dereferencing _diff. Diff is created in the constructor like so: -

_diff = boost::shared_ptr(new PhyDifferentialConstraint());

This error isn't reported when I run the test without ticking the "Analyse Stack Accesses". It doesn't show the point of allocation with the error, so it must think there is a problem with the stack. This is why I thought perhaps it was having difficulties with the boost::shared_ptr.

I am new to this, so I thought perhaps I was doing something incorrectly.

Thanks for your help
All the best,
Ash
0 Kudos
Ash_McConnell
Beginner
537 Views
Hi Matt,

I did a little experiment, I changed _diff to use a normal pointer and the error no longer is reported. There is an error reported for the other 3 lines (engine / driveshaft / gearbox) - they are using boost::shared_ptr.

So it looks like either there is a problem with boost::shared_ptr or it is a false positive.

Is there any way to ignore all the errors reported for boost::shared_ptrs? I am getting a couple of hundred problems.

Thanks for your help
All the best,
Ash

PS. The forum post editor is a bit useless :) (in Chrome at least) - I have to use shift+enter to get a line break
0 Kudos
Ash_McConnell
Beginner
537 Views
Hi Matt,

I tried _diff with the new std::shared_ptr and it seems to work (i.e. not reporting an error), seems to be boost::shared_ptr it has a problem with

All the best,
Ash
0 Kudos
Reply