hell-o !~
i faced weird problem during usage boost::pool_all ocator.
after i've changed:
with:
smth goes wrong:
before that i didn't get any sever errors...
i've found out where it breaks in my code:
smth goes wrong in boost simple_segregat ed_storage.hpp function:
here is my stack on this moment:
what is wrong with my code and where's my fault? thanks.
i faced weird problem during usage boost::pool_all ocator.
after i've changed:
Code:
typedef boost::shared_ptr< param > ParamPtr; typedef std::vector< ParamPtr > ParamPtrVector;
Code:
typedef boost::shared_ptr< param > ParamPtr; typedef std::vector< ParamPtr, [b]boost::pool_allocator<ParamPtr>[/b] > ParamPtrVector;
Segmentation fault: 11 (core dumped)
i've found out where it breaks in my code:
Code:
class UsersFunction : public Function {
boost::shared_ptr< Statement > _pStmtPtr; //body of function
public:
UsersFunction(const Function::FunctionHeader &header, const boost::shared_ptr< Statement > &pStmtPtr = boost::shared_ptr<Statement>())
: Function(header),
_pStmtPtr(pStmtPtr) {} [b]HERE !!![/b]
//...
};
//parent class
class Function {
Value _result;
public:
struct FunctionHeader {
std::string _name;
Value::E_TYPE _returnType;
std::size_t _argsCount;
ParamPtrVector _params;
FunctionHeader(const std::string &name, const Value::E_TYPE returnType, const std::size_t argsCount, const ParamPtrVector ¶ms)
:_name(name), _returnType(returnType), _argsCount(argsCount), _params(params) {}
//...
};
protected:
FunctionHeader _header;
protected:
Function(const FunctionHeader &header)
:_header(header),
_result(header.getType()) {}
~Function() {}
Function &operator=(const Function &other) {
if (this != &other) {
_header = other._header;
}
return *this;
}
public:
//...
};
Code:
//boost/simple_segregated_storage.hpp file
template <typename SizeType>
void * simple_segregated_storage<SizeType>::segregate(
void * const block,
const size_type sz,
const size_type partition_sz,
void * const end)
{
// Get pointer to last valid chunk, preventing overflow on size calculations
// The division followed by the multiplication just makes sure that
// old == block + partition_sz * i, for some integer i, even if the
// block size (sz) is not a multiple of the partition size.
char * old = static_cast<char *>(block)
+ ((sz - partition_sz) / partition_sz) * partition_sz;
// Set it to point to the end
nextof(old) = end;
// Handle border case where sz == partition_sz (i.e., we're handling an array
// of 1 element)
if (old == block)
return block;
// Iterate backwards, building a singly-linked list of pointers
for (char * iter = old - partition_sz; iter != block;
old = iter, iter -= partition_sz)
nextof(iter) = old; [b]HERE !!![/b]
// Point the first pointer, too
nextof(block) = old;
return block;
}
iter = 0x282ffff8 <error reading address 0x282ffff8: Bad address>
0x0805b0f8 boost::simple_s egregated_stora ge<unsigned int>::segregate
0x0805b158 boost::simple_s egregated_stora ge<unsigned int>::add_block
0x0805b352 boost::simple_s egregated_stora ge<unsigned int>::add_order ed_block
0x0805b3cc boost::simple_s egregated_stora ge<unsigned int>::ordered_f ree_n
0x0805b443 boost::pool<boo st::default_use r_allocator_new _delete>::order ed_free
0x0807c04c boost::singleto n_pool<boost::p ool_allocator_t ag,8,boost::def ault_user_alloc ator_new_delete ,boost::detail: :pool::pthred_m utex,32>::order ed_free
0x0807c078 boost::pool_all ocator<boost::s hared_ptr<param >,boost::defaul t_user_allocato r_new_delete,bo ost::details::p ool:pthread_mut ex,32::dealloca te
0x0807c09e std::_Vector_ba se<boost::share d_ptr<param>,bo ost::pool_alloc ator<boost::sha red_ptr<param>, boost::default_ user_allocator_ new_delete,boos t::details::poo l::pthread_mute x,32> >::_M_deallocat e
0x0807c3a6 ~_Vector_base
0x0807c562 ~vector
0x0807c5a5 ~FunctionHeader
0x0806f170 Syntaxer::Funct ionsDeclaration s
0x0806fe17 Syntaxer::run
0x0804a796 main
0x0805b0f8 boost::simple_s egregated_stora ge<unsigned int>::segregate
0x0805b158 boost::simple_s egregated_stora ge<unsigned int>::add_block
0x0805b352 boost::simple_s egregated_stora ge<unsigned int>::add_order ed_block
0x0805b3cc boost::simple_s egregated_stora ge<unsigned int>::ordered_f ree_n
0x0805b443 boost::pool<boo st::default_use r_allocator_new _delete>::order ed_free
0x0807c04c boost::singleto n_pool<boost::p ool_allocator_t ag,8,boost::def ault_user_alloc ator_new_delete ,boost::detail: :pool::pthred_m utex,32>::order ed_free
0x0807c078 boost::pool_all ocator<boost::s hared_ptr<param >,boost::defaul t_user_allocato r_new_delete,bo ost::details::p ool:pthread_mut ex,32::dealloca te
0x0807c09e std::_Vector_ba se<boost::share d_ptr<param>,bo ost::pool_alloc ator<boost::sha red_ptr<param>, boost::default_ user_allocator_ new_delete,boos t::details::poo l::pthread_mute x,32> >::_M_deallocat e
0x0807c3a6 ~_Vector_base
0x0807c562 ~vector
0x0807c5a5 ~FunctionHeader
0x0806f170 Syntaxer::Funct ionsDeclaration s
0x0806fe17 Syntaxer::run
0x0804a796 main