Opened 4 years ago

Closed 4 years ago

#9064 closed Bugs (fixed)

select_on_container_copy_construction for scoped_allocator segfaults

Reported by: Markus Mathes <Markus.Mathes@…> Owned by: igaztanaga
Milestone: To Be Determined Component: container
Version: Boost 1.54.0 Severity: Regression
Keywords: Cc:


using gcc 4.4.7 or 4.6.3 for linux the following code segfaults due to a problem with select_on_container_copy_construction

#include <memory>
#include <boost/container/scoped_allocator.hpp>
#include <boost/container/vector.hpp>

int main(int argc, char* argv[]) {
   typedef boost::container::scoped_allocator_adaptor<std::allocator<int> > Allocator;
   typedef boost::container::vector<int, Allocator> MyVector;

   MyVector test1;
   MyVector test2(test1);

Attachments (1)

select_on_conatiner_copy.patch (1.6 KB) - added by Markus Mathes <Markus.Mathes@…> 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

The same code runs fine with boost 1.52.0

comment:2 Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

The inner_traits_type::select_on_container_copy_construction(this->inner_allocator()) statement in select_on_container_copy_construction causes an infinite recursion loop for a scoped allocator without any inner allocator type. (Inner allocator points back to outer) Somehow one has to distinguish the cases without and with inner allocator. In the latter case skipping the inner_traits_type::select_on_container_copy_construction part in the constructor call could be used to break the loop.

Changed 4 years ago by Markus Mathes <Markus.Mathes@…>

comment:3 Changed 4 years ago by igaztanaga

Thanks for the report and the patch. I've modified it to pass the logic to the bass class, where an specialization for 0 inner alllocator can handle select_on_container_copy_construction a bit differently.

comment:4 Changed 4 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from new to closed

(In [85537]) Fixes #9064

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.