Michael E. Brasher | 1 Aug 2006 16:20
Picon

RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption? - Pegasus::Array<> issue

 
-----Original Message-----
From: John McLaughlin [mailto:jmclaughlin <at> istor.com]
Sent: Monday, July 31, 2006 5:02 PM
To: Huy Do; pegasus-l <at> openpegasus.org
Subject: RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption? - Pegasus::Array<> issue

Huy,
 
I understand the intent of "virtual".  I am just alerting others to a possible source of memory corruption.
 
The example provided, while not needing virtual, is legal C++ and does cause memory corruption.  I present this experience for any that may be having problems of corruption with a "proper" virtual/multiple-inheritance object collection.
 
In our case, the virtual was not needed.
 
John
 
___________________________________________________
John McLaughlin - iStor Networks - (949) 753-8999 x149
 
 

From: Huy Do [mailto:huy.do <at> qlogic.com]
Sent: Monday, July 31, 2006 2:30 PM
To: John McLaughlin; pegasus-l <at> openpegasus.org
Subject: RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption? - Pegasus::Array<> issue

John,
Generally, virtual base classes are most suitable when the classes that derive from the virtual base, and especially the virtual base itself, are pure abstract classes.
 
What was the reason you use virtual inheritance for class B?
   - Huy

From: John McLaughlin [mailto:jmclaughlin <at> istor.com]
Sent: Monday, July 31, 2006 2:03 PM
To: pegasus-l <at> openpegasus.org
Subject: RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption? - Pegasus::Array<> issue

Here's a follow-up on my memory corruption issue that might be of use to others.
 
I have not dissected the Pegasus code carefully to confirm, but empirical evidence strongly suggests that Pegasus::Array<> containers for objects  that use "virtual" inheritance will often yield corrupt objects in the Array.
 
This is probably an uncommon scenario (due to the infrequency of "virtual" multiple inheritance), but be aware of a possible problem.
 
A trivial C++ declaration example which presents the problem scenario is:
 
class A
{
    ...
};
 
class B : public virtual A
{
    ...
};
 
Pegasus::Array<B>    my_B_array;
 
This is not the intended use of virtual, but it shows the minimal failure conditions.
 
John
 
___________________________________________________
John McLaughlin - iStor Networks - (949) 753-8999 x149
 
 

From: John McLaughlin
Sent: Wednesday, July 19, 2006 12:58 PM
To: David Dillard
Cc: pegasus-l <at> openpegasus.org
Subject: RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption?

David,
 
I suspect your theory is correct.
 
Does anyone here have any experience with a good open-source heap management/diagnostic package?
 
John
 
___________________________________________________
John McLaughlin - iStor Networks - (949) 753-8999 x149
 
 

From: David Dillard [mailto:david_dillard <at> symantec.com]
Sent: Wednesday, July 19, 2006 8:03 AM
To: John McLaughlin
Cc: pegasus-l <at> openpegasus.org
Subject: RE: Boolean System::isPrivilegedUser(const String& userName) memory corruption?

A guess:
 
Try memset'ing pwd before the call to getpwnam_r.  Some docs for getpwnam_r say it UPDATES the pwd structure, so if a seemingly initialized pointer is already in the structure then maybe the function tries to reuse the space?
 
Other than that, maybe it's just a corrupted heap from who knows when that just happens to show itself on this call.  You could always just change this function to always return true.  If that just causes corruption at later point it's likely not the call to getpwnam_r that's the problem, but something earlier in the code.
 
 
--- David
 

From: John McLaughlin [mailto:jmclaughlin <at> istor.com]
Sent: Tuesday, July 18, 2006 3:22 PM
To: pegasus-l <at> openpegasus.org
Subject: Boolean System::isPrivilegedUser(const String& userName) memory corruption?

I have a provider global variable (a Pegasus Array of objects) that is getting corrupted at run-time and I have traced the time of the corruption back to a Pegasus internal funtion call to a Linux run-time library function.  Neither of these functions have *any* visibility of my data that is being corrupted.
 
Before the call:
    if (getpwnam_r(userName.getCString(), &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
in Pegasus/Common/SystemUnix.cpp
 
my data is fine.  After the call my data is corrupted.
 
Anyone have any ideas?
 
John
 
FYI...
    # define PEGASUS_PRODUCT_VERSION "2.5.1"
_______________________________
John McLaughlin
iStor Networks, Inc.
(949) 753-8999 x149
 
 

Gmane