bugCERTI - Bugs: bug #24691, Bug in getParameterName

 
 

bug #24691: Bug in getParameterName

Submitted by:  Christian Stenzel <approx>
Submitted on:  Wed 29 Oct 2008 03:54:29 PM UTC  
 
Category: CERTISeverity: 3 - Normal
Item Group: Software errorStatus: Ready For Test
Privacy: PublicAssigned to: Eric NOULARD <erk>
Open/Closed: ClosedRelease: 3.3.1
Reproducibility: NoneFixed Release: 3.3.2

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 30 Oct 2008 10:13:07 AM UTC, comment #7:

I've just checked in the fix.

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Thu 30 Oct 2008 10:02:13 AM UTC, comment #6:

Hi Florian,

Yes your are damn right.
We use a temporary as return value...
The fact is we must get rid of char* usage
and prefer
std::string
and/or
const std::string&

I'll make that change for the getParameterName.
We could do that safely for ALL internal CERTI API.

I'll open a task for that.

A sidenote to Florian:
May be you can open a Savannah account and get logged
when updating the tracker, this way you'll get follow-up.

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Thu 30 Oct 2008 07:42:28 AM UTC, comment #5:

Hi Guys,

the codes

return getParameterByHandle(the_handle)->getCName();

return getParameterByHandle(the_handle)->getName().c_str();

looks equal, but there is a small different.

getParameterByHandle(the_handle)->getName() returns a copy (!) of the string in the parameter-object. This copy is a local object in the surrounding Interaction::getParameterName(...) method. The c_str() only returns a pointer IN this new created string-object, which will be deleted after the the closing bracket of the surrounding Method. So the pointer points somewhere to the stack-memory ...

This creates the way throw the method-stacks an empty-string (which was called by Christian and me a Null-string, which is in my eyes a difference from a Null-pointer).

Greetings Florian

Anonymous
Wed 29 Oct 2008 07:51:54 PM UTC, comment #4:

I've forget to mention our dev system:

win2k
ms visual 2005

Christian Stenzel <approx>
Project Member
Wed 29 Oct 2008 06:54:07 PM UTC, comment #3:

Hi Eric,

today we had the problem to get a string of a
parameter name by invoking the service getParameterName.

E.g. the name of a parameter in the fed file is height.
A sender transmits the parameter to a receiver. The receiver
estimates the parameter string within the callback
receiveINteraction by calling getParameterName(parameterHandle).

This always results in a empty return value.

The small mentioned modification solved our problem.

Was only a small and dirty hack :), perhaps anyone
can test that behaviour too.

This occurs in the current CVS tree and in the last CERTI
release.

So long,
Christian

Christian Stenzel <approx>
Project Member
Wed 29 Oct 2008 05:08:35 PM UTC, comment #2:

In fact I'm pretty sure it fixed the bug in some way.

With the Petr modification the returned string won't ever
be a NULL pointer but it may be a null length string
i.e. containing only a '\0'.

However it doesn't look like a "normal" parameter
to be "".

May be there is something I do not understand in this bug
since your code:

return getParameterByHandle(the_handle)->getCName();

is equivalent to the current code:
return getParameterByHandle(the_handle)->getName().c_str();

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Wed 29 Oct 2008 05:00:36 PM UTC, comment #1:

This may have already been fixed by Petr
modification for handling char* returned value
using "hla_strdup".

Look at related bug 24538

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Wed 29 Oct 2008 03:54:29 PM UTC, original submission:

Hi all,

just discovered a small bug in rtiAmb, getParameterName() which
returns a Null string.

We have no diff and patching tools here that's why a short description and solution:

We changed a small line within the Interaction.cc file.

const char *
Interaction::getParameterName(ParameterHandle the_handle) const
throw (InteractionParameterNotDefined,
RTIinternalError)
{
return getParameterByHandle(the_handle)->getCName();
}

Many thanks to Florian.

So long,
Christian

Christian Stenzel <approx>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by erk (Posted a comment)
  • -unavailable- added by approx (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 29 Apr 2009 09:07:59 AM UTCerkOpen/ClosedOpen=>Closed
      Fixed ReleaseCVS=>3.3.2
    Thu 30 Oct 2008 10:13:07 AM UTCerkStatusIn Progress=>Ready For Test
    Thu 30 Oct 2008 10:02:13 AM UTCerkStatusNeed Info=>In Progress
      Assigned toNone=>erk
    Wed 29 Oct 2008 05:00:57 PM UTCerkDependencies-=>Depends on bugs #24538
    Wed 29 Oct 2008 05:00:36 PM UTCerkStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1