|
From: jody <jod...@gm...> - 2010-02-01 13:21:46
|
Hi
In a static method of class a i have the lines
605: if (pLocation != NULL) {
606: printf("Location ok\n");
607: }
608: if (iSpecies == 0) {
609: printf("Species = 0\n");
610: }
611: Agent *pAgent = pLocation->getVegAgent(iSpecies);
612: // next line has uninitialized error
613: if (pAgent != NULL) {
614: pAgent->fromArray(pData+LOCATION_SIZE);
615: }
The method used in line 611 is in a different class:
267:Agent *Cell::getVegAgent(spcid id) const {
268: Agent *pAgent = NULL;
269: if (id < NUM_VEG) {
270: pAgent = m_apVegetation[id];
271: }
272: // this is to check for uninitialized
273: if (pAgent == NULL) {
274: pAgent = NULL;
275: }
276: return pAgent;
277:}
When i run my application with valgrind, the first error to appear is:
==16915== Conditional jump or move depends on uninitialised value(s)
==16915== at 0x815A0ED:
AgentPacker::updateVegiAgentFromArray2(float*, Population const*,
unsigned int) (AgentPacker.cpp:613)
I inserted various if-statem,ents in the code above to "catch"
uninitialized variables,
but the ' if (pAgent != NULL) {' is the only one that triggers a
'Conditional jump ..' message from valgrind.
It looks like pAgent goes uninitialized between return statement line
276 in the second class and
the call in line 611.
So the first question is of course, if i have interpreted the results
correctly, i.e. pAgent is uninitialized
only after it is returned from the method, but is ok inside the method.
If this is true, how can this happen?
Thank YOu
Jody
|
|
From: Dan K. <da...@ke...> - 2010-02-01 13:40:29
|
Maybe the array is uninitialised. Try printing it out. Print any value you
don't trust.
On Feb 1, 2010 5:22 AM, "jody" <jod...@gm...> wrote:
Hi
In a static method of class a i have the lines
605: if (pLocation != NULL) {
606: printf("Location ok\n");
607: }
608: if (iSpecies == 0) {
609: printf("Species = 0\n");
610: }
611: Agent *pAgent = pLocation->getVegAgent(iSpecies);
612: // next line has uninitialized error
613: if (pAgent != NULL) {
614: pAgent->fromArray(pData+LOCATION_SIZE);
615: }
The method used in line 611 is in a different class:
267:Agent *Cell::getVegAgent(spcid id) const {
268: Agent *pAgent = NULL;
269: if (id < NUM_VEG) {
270: pAgent = m_apVegetation[id];
271: }
272: // this is to check for uninitialized
273: if (pAgent == NULL) {
274: pAgent = NULL;
275: }
276: return pAgent;
277:}
When i run my application with valgrind, the first error to appear is:
==16915== Conditional jump or move depends on uninitialised value(s)
==16915== at 0x815A0ED:
AgentPacker::updateVegiAgentFromArray2(float*, Population const*,
unsigned int) (AgentPacker.cpp:613)
I inserted various if-statem,ents in the code above to "catch"
uninitialized variables,
but the ' if (pAgent != NULL) {' is the only one that triggers a
'Conditional jump ..' message from valgrind.
It looks like pAgent goes uninitialized between return statement line
276 in the second class and
the call in line 611.
So the first question is of course, if i have interpreted the results
correctly, i.e. pAgent is uninitialized
only after it is returned from the method, but is ok inside the method.
If this is true, how can this happen?
Thank YOu
Jody
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the
business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Valgrind-users mailing list
Val...@li...
https://lists.sourceforge.net/lists/listinfo/valgrind-users
|
|
From: jody <jod...@gm...> - 2010-02-01 14:23:00
|
I accidentally replied tpo Julian only.
Here it is for the list.
Sorry, jody
---------- Forwarded message ----------
From: jody <jod...@gm...>
Date: Mon, Feb 1, 2010 at 3:21 PM
Subject: Re: [Valgrind-users] variable goes uninitialized after
'return' of method
To: Julian Seward <js...@ac...>
Thank you for your replies
I did run it with 'track-origins=yes' and the culprit was indeed the
array m_apVegetation.
But if m_apVegetation[id] is uninitialized, shouldn't it be reported
as such in the if statement below at line 273 (after this uninitialized
value has been saved in pAgent)?
Or do i misunderstand something on how these uninitialized values behave?
Thank you
Jody
On Mon, Feb 1, 2010 at 2:55 PM, Julian Seward <js...@ac...> wrote:
>
>> The method used in line 611 is in a different class:
>> 267:Agent *Cell::getVegAgent(spcid id) const {
>> 268: Agent *pAgent = NULL;
>> 269: if (id < NUM_VEG) {
>> 270: pAgent = m_apVegetation[id];
>> 271: }
>> 272: // this is to check for uninitialized
>> 273: if (pAgent == NULL) {
>> 274: pAgent = NULL;
>> 275: }
>> 276: return pAgent;
>> 277:}
>>
>> When i run my application with valgrind, the first error to appear is:
>> ==16915== Conditional jump or move depends on uninitialised value(s)
>> ==16915== at 0x815A0ED:
>> AgentPacker::updateVegiAgentFromArray2(float*, Population const*,
>> unsigned int) (AgentPacker.cpp:613)
>>
>> I inserted various if-statem,ents in the code above to "catch"
>> uninitialized variables,
>> but the ' if (pAgent != NULL) {' is the only one that triggers a
>> 'Conditional jump ..' message from valgrind.
>> It looks like pAgent goes uninitialized between return statement line
>> 276 in the second class and
>> the call in line 611.
>
> I would guess m_apVegetation[id] is uninitialised.
>
> Try --track-origins=yes for Valgrind. That might help show
> where the root cause of the problem is.
>
> J
>
|
|
From: Julian S. <js...@ac...> - 2010-02-02 03:06:53
|
> The method used in line 611 is in a different class:
> 267:Agent *Cell::getVegAgent(spcid id) const {
> 268: Agent *pAgent = NULL;
> 269: if (id < NUM_VEG) {
> 270: pAgent = m_apVegetation[id];
> 271: }
> 272: // this is to check for uninitialized
> 273: if (pAgent == NULL) {
> 274: pAgent = NULL;
> 275: }
> 276: return pAgent;
> 277:}
>
> When i run my application with valgrind, the first error to appear is:
> ==16915== Conditional jump or move depends on uninitialised value(s)
> ==16915== at 0x815A0ED:
> AgentPacker::updateVegiAgentFromArray2(float*, Population const*,
> unsigned int) (AgentPacker.cpp:613)
>
> I inserted various if-statem,ents in the code above to "catch"
> uninitialized variables,
> but the ' if (pAgent != NULL) {' is the only one that triggers a
> 'Conditional jump ..' message from valgrind.
> It looks like pAgent goes uninitialized between return statement line
> 276 in the second class and
> the call in line 611.
I would guess m_apVegetation[id] is uninitialised.
Try --track-origins=yes for Valgrind. That might help show
where the root cause of the problem is.
J
|
|
From: Konstantin S. <kon...@gm...> - 2010-02-02 07:43:15
|
On Mon, Feb 1, 2010 at 5:22 PM, jody <jod...@gm...> wrote: > I accidentally replied tpo Julian only. > Here it is for the list. > Sorry, jody > > ---------- Forwarded message ---------- > From: jody <jod...@gm...> > Date: Mon, Feb 1, 2010 at 3:21 PM > Subject: Re: [Valgrind-users] variable goes uninitialized after > 'return' of method > To: Julian Seward <js...@ac...> > > > Thank you for your replies > > I did run it with 'track-origins=yes' and the culprit was indeed the > array m_apVegetation. > > But if m_apVegetation[id] is uninitialized, shouldn't it be reported > as such in the if statement below at line 273 (after this uninitialized > value has been saved in pAgent)? > Section 5.3 of the FAQ has the answer: http://valgrind.org/docs/manual/faq.html#faq.undeferrors --kcc > Or do i misunderstand something on how these uninitialized values behave? > > Thank you > Jody > > On Mon, Feb 1, 2010 at 2:55 PM, Julian Seward <js...@ac...> wrote: > > > >> The method used in line 611 is in a different class: > >> 267:Agent *Cell::getVegAgent(spcid id) const { > >> 268: Agent *pAgent = NULL; > >> 269: if (id < NUM_VEG) { > >> 270: pAgent = m_apVegetation[id]; > >> 271: } > >> 272: // this is to check for uninitialized > >> 273: if (pAgent == NULL) { > >> 274: pAgent = NULL; > >> 275: } > >> 276: return pAgent; > >> 277:} > >> > >> When i run my application with valgrind, the first error to appear is: > >> ==16915== Conditional jump or move depends on uninitialised value(s) > >> ==16915== at 0x815A0ED: > >> AgentPacker::updateVegiAgentFromArray2(float*, Population const*, > >> unsigned int) (AgentPacker.cpp:613) > >> > >> I inserted various if-statem,ents in the code above to "catch" > >> uninitialized variables, > >> but the ' if (pAgent != NULL) {' is the only one that triggers a > >> 'Conditional jump ..' message from valgrind. > >> It looks like pAgent goes uninitialized between return statement line > >> 276 in the second class and > >> the call in line 611. > > > > I would guess m_apVegetation[id] is uninitialised. > > > > Try --track-origins=yes for Valgrind. That might help show > > where the root cause of the problem is. > > > > J > > > > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > > > |
|
From: jody <jod...@gm...> - 2010-02-02 10:20:43
|
Thanks - i think the client-request VALGRIND_CHECK_VALUE_IS_DEFINED is what i'm looking for. Jody On Tue, Feb 2, 2010 at 8:42 AM, Konstantin Serebryany <kon...@gm...> wrote: > > > On Mon, Feb 1, 2010 at 5:22 PM, jody <jod...@gm...> wrote: >> >> I accidentally replied tpo Julian only. >> Here it is for the list. >> Sorry, jody >> >> ---------- Forwarded message ---------- >> From: jody <jod...@gm...> >> Date: Mon, Feb 1, 2010 at 3:21 PM >> Subject: Re: [Valgrind-users] variable goes uninitialized after >> 'return' of method >> To: Julian Seward <js...@ac...> >> >> >> Thank you for your replies >> >> I did run it with 'track-origins=yes' and the culprit was indeed the >> array m_apVegetation. >> >> But if m_apVegetation[id] is uninitialized, shouldn't it be reported >> as such in the if statement below at line 273 (after this uninitialized >> value has been saved in pAgent)? > > Section 5.3 of the FAQ has the > answer: http://valgrind.org/docs/manual/faq.html#faq.undeferrors > --kcc > >> >> Or do i misunderstand something on how these uninitialized values behave? >> >> Thank you >> Jody >> >> On Mon, Feb 1, 2010 at 2:55 PM, Julian Seward <js...@ac...> wrote: >> > >> >> The method used in line 611 is in a different class: >> >> 267:Agent *Cell::getVegAgent(spcid id) const { >> >> 268: Agent *pAgent = NULL; >> >> 269: if (id < NUM_VEG) { >> >> 270: pAgent = m_apVegetation[id]; >> >> 271: } >> >> 272: // this is to check for uninitialized >> >> 273: if (pAgent == NULL) { >> >> 274: pAgent = NULL; >> >> 275: } >> >> 276: return pAgent; >> >> 277:} >> >> >> >> When i run my application with valgrind, the first error to appear is: >> >> ==16915== Conditional jump or move depends on uninitialised value(s) >> >> ==16915== at 0x815A0ED: >> >> AgentPacker::updateVegiAgentFromArray2(float*, Population const*, >> >> unsigned int) (AgentPacker.cpp:613) >> >> >> >> I inserted various if-statem,ents in the code above to "catch" >> >> uninitialized variables, >> >> but the ' if (pAgent != NULL) {' is the only one that triggers a >> >> 'Conditional jump ..' message from valgrind. >> >> It looks like pAgent goes uninitialized between return statement line >> >> 276 in the second class and >> >> the call in line 611. >> > >> > I would guess m_apVegetation[id] is uninitialised. >> > >> > Try --track-origins=yes for Valgrind. That might help show >> > where the root cause of the problem is. >> > >> > J >> > >> >> >> ------------------------------------------------------------------------------ >> The Planet: dedicated and managed hosting, cloud storage, colocation >> Stay online with enterprise data centers and the best network in the >> business >> Choose flexible plans and management services without long-term contracts >> Personal 24x7 support from experience hosting pros just a phone call away. >> http://p.sf.net/sfu/theplanet-com >> _______________________________________________ >> Valgrind-users mailing list >> Val...@li... >> https://lists.sourceforge.net/lists/listinfo/valgrind-users >> >> > > |