473,785 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using boost::pool_all ocator<T> ?

Hi,

I've experimenting with using boost::pool_all ocator 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 getting this

// Include files
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include "boost/pool/pool_alloc.hpp"

//--- Example main program
int main ( int argc, char** argv )
{
typedef std::vector< int, boost::pool_all ocator<int Vector;
typedef std::map< int, Vector Map;

Vector v;
v.push_back(10) ;

Map map;
map[2].push_back(10);

return 0;
}

gives

Program received signal SIGSEGV, Segmentation fault.
0x080497bc in boost::simple_s egregated_stora ge<unsigned int>::segregate
(block=0x9d1109 8, sz=0, partition_sz=4,
end=0x9d111d0)
at /usr/include/boost/pool/simple_segregat ed_storage.hpp: 207
207 nextof(iter) = old;
(gdb) where
#0 0x080497bc in boost::simple_s egregated_stora ge<unsigned int>::segregate
(block=0x9d1109 8, sz=0,
partition_sz=4, end=0x9d111d0)
at /usr/include/boost/pool/simple_segregat ed_storage.hpp: 207
#1 0x08049818 in boost::simple_s egregated_stora ge<unsigned int>::add_block
(this=0x804d818 , block=0x9d11098 ,
nsz=0, npartition_sz=4 )
at /usr/include/boost/pool/simple_segregat ed_storage.hpp: 72
#2 0x08049a36 in boost::simple_s egregated_stora ge<unsigned
int>::add_order ed_block (this=0x804d818 ,
block=0x9d11098 , nsz=0, npartition_sz=4 )
at /usr/include/boost/pool/simple_segregat ed_storage.hpp: 89
#3 0x08049aa4 in boost::simple_s egregated_stora ge<unsigned
int>::ordered_f ree_n (this=0x804d818 ,
chunks=0x9d1109 8, n=0, partition_size= 4)
at /usr/include/boost/pool/simple_segregat ed_storage.hpp: 159
#4 0x08049b19 in
boost::pool<boo st::default_use r_allocator_new _delete>::order ed_free
(this=0x804d818 ,
chunks=0x9d1109 8, n=0) at /usr/include/boost/pool/pool.hpp:268
#5 0x0804a30d in boost::singleto n_pool<boost::p ool_allocator_t ag, 4u,
boost::default_ user_allocator_ new_delete,
boost::details: :pool::pthread_ mutex, 32u>::ordered_f ree (ptr=0x9d11098,
n=0)
at /usr/include/boost/pool/singleton_pool. hpp:101
#6 0x0804a358 in boost::pool_all ocator<int,
boost::default_ user_allocator_ new_delete,
boost::details: :pool::pthread_ mutex, 32u>::deallocat e (ptr=0x9d11098, n=0)
at /usr/include/boost/pool/pool_alloc.hpp: 107
#7 0x0804a378 in std::_Vector_ba se<int, boost::pool_all ocator<int,
boost::default_ user_allocator_ new_delete,
boost::details: :pool::pthread_ mutex, 32u::_M_dealloc ate
(this=0xbffed85 8, __p=0x9d11098, __n=0)

at /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:13 3
#8 0x0804a3b0 in ~_Vector_base (this=0xbffed85 8)

at /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:11 9
#9 0x0804a3f4 in ~vector (this=0xbffed85 8)

at /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:27 2
#10 0x0804a436 in ~pair (this=0xbffed85 4)

at /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_pair.h:69
#11 0x0804b040 in std::map<int, std::vector<int , boost::pool_all ocator<int,
boost::default_ user_allocator_ new_delete,
boost::details: :pool::pthread_ mutex, 32u, std::less<int>,
std::allocator< std::pair<int const, std::vector<int ,
boost::pool_all ocator<int, boost::default_ user_allocator_ new_delete,
boost::details: :pool::pthread_ mutex, 32u >::operator[]
(this=0xbffed8a c, __k=@0xbffed8dc )

at /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_map.h:348
#12 0x08048cfd in main () at main.cpp:21
what I am doing wrong

Mar 25 '07 #1
3 6410
On Sun, 25 Mar 2007 15:33:23 +0200, Chris Jones <jo****@hep.phy .cam.ac.uk
wrote:
Hi,

I've experimenting with using boost::pool_all ocator 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 getting this
It's a bug in boost::pool_all ocator (you get also a crash with VC++ 8.0)..
See
http://sourceforge.net/tracker/index...86&atid=107586
for some details.

Boris
[...]
Mar 26 '07 #2
It's a bug in boost::pool_all ocator (you get also a crash with VC++ 8.0).
See
http://sourceforge.net/tracker/index...86&atid=107586
for some details.

Boris
>[...]
Hi,

Thanks for your reply. I guess I will just have to work around thins
problem. Judging by the post dates, the bug has been around for some time.
Any idea if a fix is coming or not ?

FYI I've discover that the other reason I was getting segmentation
violations was due to requests for vectors of size 0. i.e.

std::vector<int v1(0); // works fine
std::vector<int ,boost::pool_al locator<int v2(0); // causes a segmentation
violation when v2 goes out of scope.

same problem ?

cheers Chris
Mar 27 '07 #3
On Tue, 27 Mar 2007 23:53:21 +0200, Chris Jones <jo****@hep.phy .cam.ac.uk>
wrote:
[...]Thanks for your reply. I guess I will just have to work around thins
problem. Judging by the post dates, the bug has been around for some
Yes, you have to remove pool_allocator from the inner vector.
time.
Any idea if a fix is coming or not ?
I don't know. I think there hasn't been anyone working on this problem so
far.
FYI I've discover that the other reason I was getting segmentation
violations was due to requests for vectors of size 0. i.e.

std::vector<int v1(0); // works fine
std::vector<int ,boost::pool_al locator<int v2(0); // causes a
segmentation
violation when v2 goes out of scope.

same problem ?
Hm, don't know really. If you want to be sure you better submit another
bug report. :)

Boris
Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3782
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 to release the memory, so the program should have knowledge of the elem_size, sometime, it's impossible or at least hard to know the size of the element allocated by the allocator. for example: struct my_tag list<int, boost::pool_allocator<int...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.