Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7928 closed Bugs (fixed)

boost::interprocess::shared_memory_object creation cause infinite loop

Reported by: lsopko@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.52.0 Severity: Showstopper
Keywords: Cc:

Description

Call of boost::interprocess::shared_memory_object creation cause infinite loop in case there is: boost::interprocess::shared_memory_object shm ( boost::interprocess::open_or_create, "some-name", boost::interprocess::read_write, 256); I dig inside of code and it happen in file:

boost/interprocess/shared_memory_object.hpp

this function :

inline bool shared_memory_object::priv_open_or_create

(ipcdetail::create_enum_t type,

const char *filename, mode_t mode, const permissions &perm)

{ .....

in switch/case: .... case ipcdetail::DoOpenOrCreate?:

{

oflag |= O_CREAT; We need a loop to change permissions correctly using fchmod, since with "O_CREAT only" shm_open we don't know if we've created or opened the file. while(1){

m_handle = shm_open(m_filename.c_str(), oflag, unix_perm); if(m_handle >= 0){

::fchmod(m_handle, unix_perm); break;

} else if(errno == EEXIST){

if((m_handle = shm_open(m_filename.c_str(), oflag, unix_perm)) >= 0
errno != ENOENT){

break;

}

}

}

}

... as you can see there is a while and this while will remain infinite in case of any other errno then: "EEXIST"

... there are 9 different errors possible in case of shm_open() call, so they should be handled, in my case it was EACCES what brick my testing.

I'm testing it on 1.50 but saw 1.52 have the same code .....

Reagards

Ladislav Sopko lsopko@…

Attachments (0)

Change History (7)

comment:1 Changed 5 years ago by Ion Gaztañaga

Thanks for the report. I'll change the loop so that retries are only done if creation exactly returns EEXIST and opening returns ENOENT.

comment:2 Changed 5 years ago by Ion Gaztañaga

Resolution: fixed
Status: newclosed

(In [82802]) Fixes #7928

comment:3 Changed 5 years ago by Ion Gaztañaga

(In [82803]) Fixes #7928

comment:4 Changed 5 years ago by Ion Gaztañaga

Can you test if your problem was solved? Thanks

comment:5 Changed 5 years ago by anonymous

I'll test it asap. Thx

comment:6 Changed 5 years ago by anonymous

It worked, but in which version of boost i can have this patch?

comment:7 Changed 5 years ago by Ion Gaztañaga

I'm afraid it won't be out until Boost 1.54. We have not release date yet for that version.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.