473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

boost::pool_allocator: can't find my errors

6
hell-o !~

i faced weird problem during usage boost::pool_allocator.
after i've changed:
Expand|Select|Wrap|Line Numbers
  1. typedef boost::shared_ptr< param > ParamPtr;
  2. typedef std::vector< ParamPtr > ParamPtrVector;
  3.  
with:
Expand|Select|Wrap|Line Numbers
  1. typedef boost::shared_ptr< param > ParamPtr;
  2. typedef std::vector< ParamPtr, boost::pool_allocator<ParamPtr> > ParamPtrVector;
  3.  
smth goes wrong:
Segmentation fault: 11 (core dumped)
before that i didn't get any sever errors...

i've found out where it breaks in my code:
Expand|Select|Wrap|Line Numbers
  1. class UsersFunction : public Function {
  2.     boost::shared_ptr< Statement > _pStmtPtr; //body of function   
  3. public:
  4.     UsersFunction(const Function::FunctionHeader &header, const boost::shared_ptr< Statement > &pStmtPtr = boost::shared_ptr<Statement>())
  5.             : Function(header),
  6.             _pStmtPtr(pStmtPtr) {} HERE !!!
  7.     //...
  8. };
  9.  
  10. //parent class
  11. class Function {
  12.     Value _result;
  13. public:
  14.     struct FunctionHeader {
  15.         std::string _name;
  16.         Value::E_TYPE _returnType;
  17.         std::size_t _argsCount;
  18.         ParamPtrVector _params;
  19.         FunctionHeader(const std::string &name, const Value::E_TYPE returnType, const std::size_t argsCount, const ParamPtrVector &params)
  20.                 :_name(name), _returnType(returnType), _argsCount(argsCount), _params(params) {}
  21.  
  22.         //...
  23.     };
  24. protected:
  25.     FunctionHeader _header;
  26. protected:
  27.     Function(const FunctionHeader &header)
  28.             :_header(header),
  29.             _result(header.getType()) {}
  30.     ~Function() {}
  31.     Function &operator=(const Function &other) {
  32.         if (this != &other) {
  33.             _header = other._header;
  34.         }
  35.         return *this;
  36.     }
  37. public:
  38.  
  39.     //...
  40. };
  41.  
smth goes wrong in boost simple_segregated_storage.hpp function:
Expand|Select|Wrap|Line Numbers
  1. //boost/simple_segregated_storage.hpp file
  2. template <typename SizeType>
  3. void * simple_segregated_storage<SizeType>::segregate(
  4.     void * const block,
  5.     const size_type sz,
  6.     const size_type partition_sz,
  7.     void * const end)
  8. {
  9.   // Get pointer to last valid chunk, preventing overflow on size calculations
  10.   //  The division followed by the multiplication just makes sure that
  11.   //    old == block + partition_sz * i, for some integer i, even if the
  12.   //    block size (sz) is not a multiple of the partition size.
  13.   char * old = static_cast<char *>(block)
  14.       + ((sz - partition_sz) / partition_sz) * partition_sz;
  15.  
  16.   // Set it to point to the end
  17.   nextof(old) = end;
  18.  
  19.   // Handle border case where sz == partition_sz (i.e., we're handling an array
  20.   //  of 1 element)
  21.   if (old == block)
  22.     return block;
  23.  
  24.   // Iterate backwards, building a singly-linked list of pointers
  25.   for (char * iter = old - partition_sz; iter != block;
  26.       old = iter, iter -= partition_sz)
  27.     nextof(iter) = old;   HERE !!!
  28.  
  29.   // Point the first pointer, too
  30.   nextof(block) = old;
  31.  
  32.   return block;
  33. }
  34.  
here is my stack on this moment:
iter = 0x282ffff8 <error reading address 0x282ffff8: Bad address>
0x0805b0f8 boost::simple_segregated_storage<unsigned int>::segregate
0x0805b158 boost::simple_segregated_storage<unsigned int>::add_block
0x0805b352 boost::simple_segregated_storage<unsigned int>::add_ordered_block
0x0805b3cc boost::simple_segregated_storage<unsigned int>::ordered_free_n
0x0805b443 boost::pool<boost::default_user_allocator_new_dele te>::ordered_free
0x0807c04c boost::singleton_pool<boost::pool_allocator_tag,8, boost::default_user_allocator_new_delete,boost::de tail::pool::pthred_mutex,32>::ordered_free
0x0807c078 boost::pool_allocator<boost::shared_ptr<param>,boo st::default_user_allocator_new_delete,boost::detai ls::pool:pthread_mutex,32::deallocate
0x0807c09e std::_Vector_base<boost::shared_ptr<param>,boost:: pool_allocator<boost::shared_ptr<param>,boost::def ault_user_allocator_new_delete,boost::details::poo l::pthread_mutex,32> >::_M_deallocate
0x0807c3a6 ~_Vector_base
0x0807c562 ~vector
0x0807c5a5 ~FunctionHeader
0x0806f170 Syntaxer::FunctionsDeclarations
0x0806fe17 Syntaxer::run
0x0804a796 main
what is wrong with my code and where's my fault? thanks.
Aug 17 '08 #1
0 1804

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: sbobrows | last post by:
{Whilst I think much of this is OT for this newsgroup, I think the issue of understanding diagnostics just about gets under the door. -mod} Hi, I'm a C++ newbie trying to use the Boost regex...
1
by: GujuBoy | last post by:
i am trying to make a cpp file which will allow me to make an ARRAY and pass it as a LIST to python usin boost can someone please help...i have include <list.hpp> but i dont kno whow to access...
5
by: FBergemann | last post by:
I use SunOS 5.8, gcc 3.3.2, boost 1.33.1. I have build the entire boost package and try to compile a simple example: #include <iostream> #include <string> #include <boost/regex.hpp //...
11
by: Osiris | last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python. I found Boost. I have MS Visual Studio 2005 with C++. is this the idea: I write the following C source file:...
85
by: g | last post by:
Hello, is there any library for C as Boost is for C++? thanks in advance,
3
by: Chris Jones | last post by:
Hi, I've experimenting with using boost::pool_allocator with std::vector and gcc (4.1)., and I am having problems with segmentation violations. Below I give a simple example of one way I am...
3
by: Barry | last post by:
As boost::pool_alloc use singleton holder for pool allocator, client programmers have to reclaim the memory by hand through calling singleton_pool<alloc_tag, elem_size>::purge_memory() or something...
6
by: Juha Nieminen | last post by:
I tested the speed of a simple program like this: //------------------------------------------------------------ #include <list> #include <boost/pool/pool_alloc.hpp> int main() { typedef...
1
by: blackbiscuit | last post by:
Hi, I wanna have boost installed on my mac leopard system. I have searched through google and it seems the boost can not been directly installed but through tools like macports. Since it is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.