Opened 9 years ago

Last modified 8 years ago

#9855 new Bugs

Corruption in container::string when used with boost::interprocess

Reported by: Lars Hagström <lars@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.55.0 Severity: Showstopper
Keywords: Cc:

Description

I have found a rather strange problem in Boost.Container which I can only get to show itself when used from Boost.Interprocess. So the problem may be in either Boost.Container and Boost.Interprocess.

I have a vector of strings (in shared memory). When I push back some of these strings one of them ends up missing its null termination (c_str() returns a string which has a garbage character at the end).

I have tried to work out what the problem is, and my theory is that it is when the vector gets resized and the strings get moved into their new positions. The move semantics make the now "empty" strings "unconstructed". A new push_back will do an assign onto an unconstructed slot without "reconstructing" it. But this is where I get lost in the vector code...

I have a short test program at https://gist.github.com/DonOregano/10116264. Compile and run and it will hopefully print out some information about the error.

It appears that this error happens only on 64bit OSes. And I have only tried it on Linux (recent Ubuntu and Arch).

Change History (6)

comment:1 by anonymous, 9 years ago

Moving does not put objects in invalid "unconstructed" states

comment:2 by Lars Hagström <lars@…>, 9 years ago

No, I should have clarified that. As far as I can interpret the code it looks like the string that is moved from is left in a state where it is not null terminated.

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

I fail to reproduce the error with current trunk code in Ubuntu 12 LTS x64, both in debug and release modes, with gcc 4.6 4.7 and 4.8 in release mode. Can you test with trunk code to see if changes from 1.55 have solved this problem?

comment:4 by Lars Hagström <lars@…>, 8 years ago

I tried it with boost trunk on Arch x64 with gcc 4.8.2, and it is still happening for me.

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

Sorry for saying "trunk" (old Subversion SCM), I wanted to say the "develop" branch in Git. Which did you tried?

comment:6 by Lars Hagström <lars@…>, 8 years ago

Yeah, I do the same :-). But yes, I did try git, but the master branch...

I have now tried the develop branch instead, and I still get the problem. (And, just to be clear, I am pretty sure I'm building against the new Boost, since I get compilation errors when I add something random to managed_shared_memory.hpp).

Note: See TracTickets for help on using tickets.