Bugzilla – Bug 3500
ACE_OS::mmap(..., file_handle=ACE_INVALID_HANDLE, ...,file_mapping=0, ...): fails on ACE_TEXT_CreateFileMapping()
Last modified: 2009-01-21 14:31:03
You need to log in before you can comment on or make changes to this bug.
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); }
Could you add or extend one of the ACE tests under ACE_wrappers/tests as automated regression test
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.
Fixed, thanks!
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.
reopen
Marcel, can you integrate this test into the svn repository
test is in the repository and test stats show that the regression test works out of the box