|
From: RD on 23 Apr 2008 09:21 Thanks for the input. Code Sample I posted is not the actual code. Kind of psuedo code. >MyObjectBase doesn't have a virtual destructor, does it? Yes. Destructor in classes are virtual. > Do all modules link against the same flavor of CRT DLL? Dumpbin /imports of exe and two DLL all shows MSVCR80.DLL. Embedded (into exe/dll) assembly info of the manifest in exe and two DLLs. shows same version of VC80.CRT assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> What puzzles me that how 2008 is different from 2003. The prorgarm runs just fine on win2k3 64-bit. I fixed a __declspec (dllexport) / __declspec (dllimport) oddity. The Exe was importing class with "__declspec (dllexport)" and I changed that but program still fails. This time the frame on call stack is changed from `vector deleting destructor' to `scalar deleting destructor'. Is there a way to find out what MSVCR80!free+0xcd is trying to free? Thanks. "Igor Tandetnik" wrote: > RD <RD(a)discussions.microsoft.com> wrote: > > I've a 32-bit command line C++ utility that fails on 2008 server. Code > > compiled with VS2005. The utility works fine (and released) on > > windows 2003 (64-bit too). I don't have any sample of reasonable > > size, but here is the description. > > > > 1. Class Hierarchy in DLL > > MyObjectBase{ > > AddRef() { Count++; return; } > > Release() { if (Count <= 0) delete this; return;} > > class MyIntClass : public MyObjectBase { }; // There are other > > classes too in the hierarchy. > > MyObjectBase doesn't have a virtual destructor, does it? Without virtual > destructor, your program exhibits undefined behavior: it is illegal to > delete an instance of a derived class via a pointer to its base, unless > that base has a virtual destructor. > > Also - do you have a constructor that initialized Count? > > > This way when SmartPointer goes out of scope > > the classes on the heap get deleted. Code in GetNums.cpp is like this. > > > > int main() { > > SmartPointer<MyCMGetIPListMessage> spMsg = new MyCMGetIPListMessage; > > Do all modules link against the same flavor of CRT DLL? You are > allocating memory in one module (where main() is located), but freeing > it in another (where MyObjectBase::Release is located). This can only > work if both modules use the same memory manager, which requires them to > link to the same CRT DLL. > -- > With best wishes, > Igor Tandetnik > > With sufficient thrust, pigs fly just fine. However, this is not > necessarily a good idea. It is hard to be sure where they are going to > land, and it could be dangerous sitting under them as they fly > overhead. -- RFC 1925 > > >
From: adebaene on 23 Apr 2008 09:37 On 23 avr, 15:21, RD <R...(a)discussions.microsoft.com> wrote: > Thanks for the input. > > Code Sample I posted is not the actual code. Kind of psuedo code. > > >MyObjectBase doesn't have a virtual destructor, does it? > > Yes. Destructor in classes are virtual. > > > Do all modules link against the same flavor of CRT DLL? > > Dumpbin /imports of exe and two DLL all shows MSVCR80.DLL. > Embedded (into exe/dll) assembly info of the manifest in exe and two DLLs. > shows same version of VC80.CRT > For Visual 2008, it should be MSVCR90.DLL (same version) for ALL modules, Dlls and Exes... Is this the case? Arnaud
From: Ben Voigt [C++ MVP] on 23 Apr 2008 10:58 adebaene(a)club-internet.fr wrote: > On 23 avr, 15:21, RD <R...(a)discussions.microsoft.com> wrote: >> Thanks for the input. >> >> Code Sample I posted is not the actual code. Kind of psuedo code. >> >>> MyObjectBase doesn't have a virtual destructor, does it? >> >> Yes. Destructor in classes are virtual. >> >>> Do all modules link against the same flavor of CRT DLL? >> >> Dumpbin /imports of exe and two DLL all shows MSVCR80.DLL. >> Embedded (into exe/dll) assembly info of the manifest in exe and two >> DLLs. shows same version of VC80.CRT >> > > For Visual 2008, it should be MSVCR90.DLL (same version) for ALL > modules, Dlls and Exes... Is this the case? The OP said it was VS2005, Windows Server 2008. > > Arnaud
From: adebaene on 23 Apr 2008 11:22 On 23 avr, 16:58, "Ben Voigt [C++ MVP]" <r...(a)nospam.nospam> wrote: > adeba...(a)club-internet.fr wrote: > > On 23 avr, 15:21, RD <R...(a)discussions.microsoft.com> wrote: > >> Thanks for the input. > > >> Code Sample I posted is not the actual code. Kind of psuedo code. > > >>> MyObjectBase doesn't have a virtual destructor, does it? > > >> Yes. Destructor in classes are virtual. > > >>> Do all modules link against the same flavor of CRT DLL? > > >> Dumpbin /imports of exe and two DLL all shows MSVCR80.DLL. > >> Embedded (into exe/dll) assembly info of the manifest in exe and two > >> DLLs. shows same version of VC80.CRT > > > For Visual 2008, it should be MSVCR90.DLL (same version) for ALL > > modules, Dlls and Exes... Is this the case? > > The OP said it was VS2005, Windows Server 2008. > Argh! My bad, sorry... Arnaud
From: RD on 29 Apr 2008 15:42 I've resolved the issue. It turned out that I was not importing the C++ classes using "__declspec (dllimport)" as header files for the classes were exporting with "__declspec (dllexport)". Once I redefined macro in the files that were used for building EXE, it worked. In one place I was specifying msvcprt.dll for linking which I had to remove. I'm working with older code and I think windows 2008 enforces some of the C++ guidelines more strictly. The same code, compiled with VC++ 8.0 works fine on 2003 R2 server. "adebaene(a)club-internet.fr" wrote: > On 23 avr, 16:58, "Ben Voigt [C++ MVP]" <r...(a)nospam.nospam> wrote: > > adeba...(a)club-internet.fr wrote: > > > On 23 avr, 15:21, RD <R...(a)discussions.microsoft.com> wrote: > > >> Thanks for the input. > > > > >> Code Sample I posted is not the actual code. Kind of psuedo code. > > > > >>> MyObjectBase doesn't have a virtual destructor, does it? > > > > >> Yes. Destructor in classes are virtual. > > > > >>> Do all modules link against the same flavor of CRT DLL? > > > > >> Dumpbin /imports of exe and two DLL all shows MSVCR80.DLL. > > >> Embedded (into exe/dll) assembly info of the manifest in exe and two > > >> DLLs. shows same version of VC80.CRT > > > > > For Visual 2008, it should be MSVCR90.DLL (same version) for ALL > > > modules, Dlls and Exes... Is this the case? > > > > The OP said it was VS2005, Windows Server 2008. > > > Argh! My bad, sorry... > > Arnaud >
|
Pages: 1 Prev: Hidden window Next: Headers common to .cpp and .rc files |