Boost Users :
Subject: [Boost-users] [interprocess] garbage chars when extending interprocess strings?
From: Anthony Foiani (tkil_at_[hidden])
Date: 2011-07-31 02:39:52
I'm having a peculiar problem with interprocess strings.
0. Create the shared string type.
typedef boost::interprocess::managed_shared_memory ShmManagerType;
typedef char ShmCharType;
std::char_traits< ShmCharType >,
1. Initial write succeeds.
val = "x";
cout << quoteString( x ) << endl; // prints "x" as expected
2. When I overwrite the value with a longer value, the longer value is
stored and the length is updated -- but a null character (\0) is
inserted at the *old* length.
ShmStringType x3( "xxx" );
val = x3;
cout << quoteString( val ) << endl; // prints "x\0x" !!!
3. When I write the longer value again, it is stored correctly and
there is no \0 in the middle of the string.
val = x3;
cout << quoteString( val ) << endl; // prints "xxx" as expected
4. The same thing happens if we try a longer value again:
ShmStringType x5( "xxxxx" );
val = x5;
cout << quoteString( val ) << endl; // prints "xxx\0x"
val = x5
cout << quoteString( val ) << endl; // prints "xxxxx"
Does this ring bells for anyone?
On my embedded platform, I'm using:
And on my development workstation:
Testing this on my development workstation, I see similar issues
(although it's not always \0; in this case, I'm getting \xC0 junk
Test case at:
The output isn't the same: some cases work on one platform but not the
other, and the garbage character introduced isn't always \0.
Any ideas would be welcome.
Testing with a more current boost is a bit problematic; if someone
believes that it's been fixed in the mean time, I'll do my best to try
with a modern boost.
In the mean time, I'll just write the values twice, I guess. :)
Thanks for your time and attention!
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net