Bugzilla – Bug 1991
Unable to access ACE_Based_Pointer_Repository Singleton in a DLL
Last modified: 2005-08-29 04:15:26
You need to log in before you can comment on or make changes to this bug.
I am developing a DLL that supports shared memory mapped containers, the containers are allowed to grow in size. This means that the memory pool base addresses can be changed during the life of the application, so after each reallocation operation ACE_Based_Pointer_Basic pointers to objects in that pool must be recalculated, i.e. T *tmp; char* datap = (char*)this->array_.addr(); void *obase_addr = 0; void *nbase_addr = 0; // Find the base address associated with the <array_> pointer. // Note that it's ok for <find> to return 0, which simply // indicates that the address is not in memory-mapped virtual // address space. ACE_BASED_POINTER_REPOSITORY::instance ()->find (datap, obase_addr); ACE_ALLOCATOR_RETURN (tmp, (T *) this->allocator_->malloc (new_size * sizeof (T)), -1); ACE_BASED_POINTER_REPOSITORY::instance ()->find (tmp, nbase_addr); if(obase_addr != nbase_addr) { // Reallocation caused memory segment to move // in the virtual address space. The array_ pointer // is no longer valid, recalculate so that the // data array can be accessed this->array_ = (T*)((datap - (char*)obase_addr) + (char*) nbase_addr); } The problem is that the container DLL allocates a new instance of the Singleton ACE_Based_Pointer_Repository and the code above fails. I fixed the problem by adding the following declaration to ace/Based_Pointer_Repository.h: ACE_SINGLETON_DECLARE(ACE_Singleton, ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX) Now a single process wide instance of the ACE_Based_Pointer_Repository is used.
Steve, would you be able to create a new or modify an ACE regression test to demonstrate the problem. See ACE_wrappers/tests for the regression tests we have. We can then use this test to demonstrate the problem and test your fix. Could you also correct the version number of this report to the correct version.
Changed the ACE Version to 5.4 I will add a regression test.
we will wait then for the new regression test. Maybe you could base it on the x.4.2 release which is much newer than the x.4
Any update on the regression test?
I have been pulled onto something else, so I have not got around to this. I should be able to get back to it in the next couple of weeks. I will get a regression test to you by the end of March.
Assigned bug to reporter, we need a regression test first.
Commence work
Created an attachment (id=366) [details] Unified diff patch file of proposed fix
Attached regression test that checks for this defect and for defects detailed in 2216 and 2218
Created an attachment (id=372) [details] Proposed test for issues 1991,2216 and 2218
Fixed, thanks for the regression tests, I will have a look at the other bugs you reported soon. Mon Aug 29 09:14:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl> * ace/Based_Pointer_Repository.h: Export the based pointer repository from the dll as singleton. Fixes bugzilla bug 1919. * tests/Based_Pointer_Test.cpp: * tests/Based_Pointer_Test_Lib.cpp: New test for bugzilla bug 1919. Thanks to Steve Williams <steve at telxio dot com> for creating this test * tests/run_test.lst: Added Based_Pointer_Test * tests/tests.mpc: Added Based_Pointer_Test