Opened 15 years ago

Closed 12 years ago

#1080 closed Bugs (fixed)

boost::interprocess win32 global file mapping issue

Reported by: matroskin222@… Owned by: Ion Gaztañaga
Milestone: Boost 1.45.0 Component: interprocess
Version: Severity: Problem
Keywords: interprocess global shared memory win32 Cc:

Description

There is a serious bug in boost::interprocess library. It is unable to create global shared memory between services and simle applications. An exception is thrown ( m_err = 5, m_str = "Access is denied" ) I shortly investigated the way to fix this issue and found that call of CreateFileMappingA winAPI in winapi::create_file_mapping function sets lpAttributes parameter as NULL. To get rid of "Access is denied" error you can reimplement this function as: static inline void * create_file_mapping (void * handle, unsigned long access, unsigned long high_size, unsigned long low_size, const char * name) {

SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd;

InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sd, true, NULL, false);

sa.lpSecurityDescriptor = &sd; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = FALSE; return CreateFileMappingA (handle, &sa, access, high_size, low_size, name);

}

Change History (5)

comment:1 by Ion Gaztañaga, 15 years ago

Owner: set to Ion Gaztañaga

comment:2 by Marshall Clow, 15 years ago

Component: Noneinterprocess

comment:3 by Ion Gaztañaga, 15 years ago

Changed SVN adding suggested code. Reporter: close this bug if the problem has completely disappeared.

in reply to:  3 comment:4 by matroskin222@…, 15 years ago

Replying to igaztanaga:

Changed SVN adding suggested code. Reporter: close this bug if the problem has completely disappeared.

Problem didn't completely disappeared. You have to pass such security attributes in each WinApi call where SA parameter is required. Or allow users to specify SA by themselves.

comment:5 by Ion Gaztañaga, 12 years ago

Milestone: Boost 1.36.0Boost-1.45.0
Resolution: fixed
Status: newclosed

New permission scheme added for Boost 1.45, the user can specify permissions.

Note: See TracTickets for help on using tickets.