|
Boost Users : |
Subject: Re: [Boost-users] boost::interprocess:basic_string : Capacity no more than 10
From: samuel.gallard (samuel.gallard_at_[hidden])
Date: 2009-07-30 04:01:16
I finally managed to find which was my error. In my class Element, I used a
constructor to copy an Element like this :
Element::Element (const Element& elem){
try{
this->dir.assign(elem.getDir());
this->file.assign(elem.getFile());
this->type.assign(elem.getType());
}
catch(ip::interprocess_exception &e){
ostringstream oss;
const std::string what(e.what());
oss << "Class Element in constructor by recopy -> ";
oss << what;
throw EventException(oss.str().c_str(), __LINE__ );
}
}
If I put it in comment, I am able to use it without problems in
interprocess and define the ShmString with a length upper than 10.
But with threads (boost::thread), I am still limited to 10 if I used them
with this constructor. If it is more than 10, I obtained an error when I
create an element like this :
Element("/home/sdfqsd/","titi.txt",Request::st_change)
The error message is :
0xb7ca3283 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7ca3283 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x080600c9 in std::char_traits<char>::length (
__s=0xb8aa1130 <Address 0xb8aa1130 out of bounds>)
at /usr/include/c++/4.2/bits/char_traits.h:258
#2 0x0807c0bf in boost::interprocess::basic_string<char,
std::char_traits<char>, boost::interprocess::allocator<char,
boost::interprocess::segment_manager<char,
boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,
boost::interprocess::offset_ptr<void>, 0u>, boost::interprocess::iset_index>
> >::assign (this=0xb6bfb288, s=0xb8aa1130 <Address 0xb8aa1130 out of
bounds>)
at /usr/local/include/boost/interprocess/containers/string.hpp:988
#3 0x08079b59 in Element (this=0xb6bfb280, elem=@0xb7f4f0d0)
at ../Events/MessageQueue/Element.cpp:21
The line 21 in Element.cpp is the first line in the constructor by copy :
this->dir.assign(elem.getDir());
I don't understand why it works like that. If you could give me a clue, I
will appreciate.
About "doc_cont.cpp", it will be great to have the same example with a
vector of a class that contained basic_string attributes instead of a vector
of int. Because it is easy to understand with a basic type like int but a
little tricky to apply it to a custom type.
Regards
-- View this message in context: http://www.nabble.com/boost%3A%3Ainterprocess%3Abasic_string-%3A-Capacity-no-more-than-10-tp24675192p24733927.html Sent from the Boost - Users mailing list archive at Nabble.com.
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