First Last Prev Next    No search results available
Details
: Unable to access ACE_Based_Pointer_Repository Singleton i...
Bug#: 1991
: ACE
: ACE Core
Status: RESOLVED
Resolution: FIXED
: x86
: Windows 2000
: 5.4
: P3
: normal
: ---

:
:
: 2260
: 2216 2218
  Show dependency tree - Show dependency graph
People
Reporter: Steve Williams <steve.williams@telxio.com>
Assigned To: Steve Williams <steve.williams@telxio.com>

Attachments
Unified diff patch file of proposed fix (508 bytes, patch)
2005-08-22 21:32, Steve Williams
Details | Diff
Proposed test for issues 1991,2216 and 2218 (11.01 KB, patch)
2005-08-26 19:49, Steve Williams
Details | Diff


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2004-11-26 14:34
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.
------- Comment #1 From Johnny Willemsen 2004-11-30 06:59:13 -------
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.
------- Comment #2 From Steve Williams 2004-11-30 21:06:52 -------
Changed the ACE Version to 5.4

I will add a regression test.
------- Comment #3 From Johnny Willemsen 2004-12-02 04:23:22 -------
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
------- Comment #4 From Johnny Willemsen 2005-03-08 06:44:56 -------
Any update on the regression test?
------- Comment #5 From Steve Williams 2005-03-08 13:46:42 -------
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.
------- Comment #6 From Johnny Willemsen 2005-08-08 04:59:36 -------
Assigned bug to reporter, we need a regression test first.
------- Comment #7 From Steve Williams 2005-08-17 12:38:21 -------
Commence work
------- Comment #8 From Steve Williams 2005-08-22 21:32:27 -------
Created an attachment (id=366) [details]
Unified diff patch file of proposed fix
------- Comment #9 From Steve Williams 2005-08-26 19:37:00 -------
Attached regression test that checks for this defect and for defects detailed 
in 2216 and 2218
------- Comment #10 From Steve Williams 2005-08-26 19:49:14 -------
Created an attachment (id=372) [details]
Proposed test for issues 1991,2216 and 2218
------- Comment #11 From Johnny Willemsen 2005-08-29 04:15:26 -------
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

First Last Prev Next    No search results available