First Last Prev Next    No search results available
Details
: ACE_OS::mmap(..., file_handle=ACE_INVALID_HANDLE, ...,fil...
Bug#: 3500
: ACE
: ACE Core
Status: RESOLVED
Resolution: FIXED
: All
: Windows XP
: 5.6.6
: P3
: major
: 5.6

:
:
:
:
  Show dependency tree - Show dependency graph
People
Reporter: rizzi@softserv.com
Assigned To: Marcel Smit <msmit@remedy.nl>
:

Attachments
Regression test (1.26 KB, text/plain)
2009-01-16 13:54, rizzi@softserv.com
Details


Note

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

Related actions


Description:   Opened: 2008-11-11 12:21
ACE VERSION: 5.6 (and almost certainly 5.6.6 - the code is identical)

     HOST MACHINE and OPERATING SYSTEM:
         AMD Phenom 9950 Quad-Core - Windows XP

     TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
         (same as host)

     THE $ACE_ROOT/ace/config.h FILE :
        config-win32.h

     AREA/CLASS/EXAMPLE AFFECTED:
        ACE_OS::mmap()

     DOES THE PROBLEM AFFECT:
         COMPILATION? No
         LINKING? No
         EXECUTION? Yes

     SYNOPSIS:
        ACE_OS::mmap() fails when called with file_handle=ACE_INVALID_HANDLE
and file_mapping=0.  The intent is to create named shared memory using the
system paging file.

      DESCRIPTION:
        Calling ACE_OS::mmap() with file_handle=ACE_INVALID_HANDLE and
 file_mapping=0 will cause file_mapping to be set internally to the
 address of local_handle whose value is ACE_INVALID_HANDLE.  This results
in a call to ACE_TEXT_CreateFileMapping() with both dwMaximumSizeHigh and
dwMaximumSizeLow set to 0.  This is fine when file_handle is valid - the
maximum size of the file mapping object will be equal to the current size of
the file identified by file_handle.  However it is legal to specify an invalid
file_handle in order to create named shared memory using the system paging file
- and in this case, an error is returned if both maximum size high and low are
set to 0.

     REPEAT BY:
     void *imageBuffer =
         ACE_OS::mmap(0,  // addr
                      imageBufferSize, // len            
                      PAGE_READWRITE,  // prot            
                      MAP_SHARED, // flags           
                      ACE_INVALID_HANDLE, // file_handle
                      0,  // off
                      0, // file_mapping
                      0, // sa 
                      sharedMemory.c_str())); // name of shared memory

     SAMPLE FIX/WORKAROUND:
        Set dwMaximumSize[High|Low] to the desired length of shared memory when
fle_handle == ACE_INVALID_HANDLE. (See lines marked FIX).

   // FIX: Move these up from below
   DWORD low_off  = ACE_LOW_PART (off);
   DWORD high_off = ACE_HIGH_PART (off);

   // Only create a new handle if we didn't have a valid one passed in.
   if (*file_mapping == ACE_INVALID_HANDLE)
     {
       ...

       *file_mapping =
           ACE_TEXT_CreateFileMapping (
                file_handle,
                attr,
                prot,
                (file_handle == ACE_INVALID_HANDLE) ? high_off : 0, // FIX
                (file_handle == ACE_INVALID_HANDLE) ? low_off  : 0, // FIX
                file_mapping_name);
     }
------- Comment #1 From Johnny Willemsen 2008-11-11 13:02:29 -------
Could you add or extend one of the ACE tests under ACE_wrappers/tests as
automated regression test 
------- Comment #2 From rizzi@softserv.com 2008-11-11 16:14:48 -------
Sorry, I blew it with the bit about moving the offset variable initializations
up:

   // FIX: Move these up from below
   DWORD low_off  = ACE_LOW_PART (off);
   DWORD high_off = ACE_HIGH_PART (off);

Leave them where they are and use len, not off:

       *file_mapping =
           ACE_TEXT_CreateFileMapping (
                file_handle,
                attr,
                prot,
                0
                (file_handle == ACE_INVALID_HANDLE) ? len : 0, // FIX
                file_mapping_name);

So it's really just a one=-line fix.
------- Comment #3 From Douglas C. Schmidt 2008-11-11 16:24:34 -------
Fixed, thanks!
------- Comment #4 From rizzi@softserv.com 2009-01-16 13:54:19 -------
Created an attachment (id=1053) [details]
Regression test

I'm not sure if I need to attach the modified tests.mpc and run_test.lst as
well.
I'm about to submit a regression test for Bug# 3541.  I'll attach those files
modified for both bugs to that report.
------- Comment #5 From Johnny Willemsen 2009-01-17 13:14:42 -------
reopen
------- Comment #6 From Johnny Willemsen 2009-01-17 13:15:27 -------
Marcel, can you integrate this test into the svn repository
------- Comment #7 From Johnny Willemsen 2009-01-21 14:31:03 -------
test is in the repository and test stats show that the regression test works
out of the box

First Last Prev Next    No search results available