Please report new issues athttps://github.com/DOCGroup
Putting this discussion in Bugzilla so we won't lose this information. Hi German, German Zhivotnikov wrote: > > could someone make clear the following issue. > [snip] > > the following thing occurs: the instance of struct A is allocated by > stub, which lives in Stub.dll, while the A_var would delete this > instance within Client.exe. > > I was sure C++ idl compiler must generate operator new and operator > delete for each generated structure. However, tao_idl does not do it. > Without such operators, we face the following problem with Win32+MSVC > platform: if either Stub.dll or Client.exe, or both, are built with > static runtime (/MT switch), the heap would be corrupted, since in > Win32 each shared object built with static runtime has its own heap. > So, the ways to get things working is either > a) to use Dynamic Runtime (/MD switch), or > b) not to use this approach with separating stubs into a DLL - at > all. > The problem would not appear, had tao_idl generated (exported from > DLL) operator new and operator delete for the structures. > All of the ACE+TAO tests and examples use the Dynamic Runtime (/MD or /MDd) so this hasn't been an issue in our builds. I don't know of any applications built on TAO that are using a static runtime with user DLL's but there may be some out there. For TAO to really support this, a switch could be added to tao_idl to generate the new and delete operators as you suggest. You could send us patches or fund one of the commercial support vendors (http://www.cs.wustl.edu/~schmidt/commercial-support.html) to do it. Thanks, Adam Mitz Software Engineer Object Computing, Inc.
Hi, For structures, wouldn't this be as simple as having the IDL compiler generate ACE_ALLOC_HOOK_DECLARE in the structure body? And generate ACE_ALLOC_HOOK_DEFINE(...) in the cpp file? For instance: HEADER FILE: struct A { /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; . . . }; CPP FILE: ACE_ALLOC_HOOK_DEFINE(A) Thanks, Abdul
Hi Abdul, Yes, I think that should work. German, can you try to use the macros Abdul has pointed out and handcraft a generated file and see if that works and let us know the results? Regards, Johnny Willemsen Remedy IT Postbus 101 2650 AC Berkel en Rodenrijs The Netherlands www.theaceorb.nl / www.remedy.nl
ACE_ALLOC_HOOK_DEFINE uses "new char[]" to allocate memory. I'm not sure why we would want this. Why not just defer to global operators new and delete? Thanks, Adam
Adam, It isn't clear to me either why "new char[]" is used either. Maybe when ACE first started out in the early 90s some compilers didn't have it? At any rate, ACE_ALLOC_HOOK needs some enhancements. Look at Bugzilla 2842 for details. http://deuce.doc.wustl.edu/bugzilla/0 Thanks, Abdul
added depends, changed severity
enhancement