Opened 18 years ago

Closed 13 years ago

Last modified 12 years ago

#386 closed Bugs (fixed)

boost::pool_allocator breaks with vector of vectors

Reported by: glr9940 Owned by: shammah
Milestone: Component: pool
Version: None Severity: Problem
Keywords: Cc:

Description (last modified by Marshall Clow)

The resulting executable built with the following code 
under GCC 3.3.5 produces a segmentation fault when 
run:

Note that switching the definition of EventVector to use 
a vector with a standard allocator will fix the problem.

Also note that the definition of IndexVector doesn't seem 
to matter.

#include <boost/pool/pool_alloc.hpp>
#include <vector>
#include <iostream>

template <typename DataType>
struct PooledVector {
       typedef std::vector<DataType, 
boost::pool_allocator<DataType> >      Type;
};

typedef PooledVector<int>::Type EventVector;
//typedef std::vector<int>      EventVector;

//typedef PooledVector<EventVector>::Type       
IndexVector;
typedef std::vector<EventVector>        IndexVector;

int main() {
               IndexVector iv;
               iv.push_back(EventVector());
               iv.back().push_back(3);
               std::cout << "it works\n";
       return 0;
}

Attachments (1)

pool.patch (1.7 KB ) - added by Steven Watanabe 13 years ago.
patch and test case.

Download all attachments as: .zip

Change History (10)

comment:1 by nobody, 17 years ago

Logged In: NO 

I have the same problem making a
std::vector<std::vector<int, boost::pool_allocator<int> > >
on gcc 3.4.4




comment:2 by nobody, 16 years ago

Logged In: NO 

Having the same problem under MingW gcc 3.4.4 w/ STLPort 5.0
on Cygwin32.

comment:3 by verntx, 16 years ago

Logged In: YES 
user_id=1568291

ok, logged in now.
Having the same problem under MingW gcc 3.4.4 w/ STLPort 5.0
on Cygwin32.

Going to try enabling a lot of the STLport debugging stuff
to see if I can catch the allocators interfering w/ each other.

comment:4 by anonymous, 15 years ago

Under 1.33.1 with VS2005 I get a crash with a deque< object, boost::pool_allocator< object> >

Crash is in simple_segregated_storage<SizeType>::try_malloc_n

comment:5 by Marshall Clow, 15 years ago

Component: Nonepool
Description: modified (diff)
Severity: Showstopper

comment:6 by Marshall Clow, 15 years ago

Severity: ShowstopperProblem

comment:7 by Steven Watanabe, 13 years ago

This is probably the same as #2869

by Steven Watanabe, 13 years ago

Attachment: pool.patch added

patch and test case.

comment:8 by Steven Watanabe, 13 years ago

Resolution: Nonefixed
Status: assignedclosed

(In [56998]) Allow zero-sized blocks to be allocated by malloc_n. Fixes #386

comment:9 by Marshall Clow, 12 years ago

(In [67958]) Merging fixes to release; Fixes #2696; Refs #4346; Refs #2941; Refs #386

Note: See TracTickets for help on using tickets.