By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

Segmentation fault in copy algorithm

P: n/a
Hi,

I wrote a template to use copy() algorithm, called copyAll:
template<class T>
void copyAll(const T& src , T& dest ) {
copy (src.begin(), src.end(), back_inserter(dest));
}

but when I call it, I get a segmentation fault:
Thread [0] (Suspended: Signal 'SIGSEGV' received. Description:
Segmentation fault.)
21 __gnu_cxx::__mt_alloc_base<BlockData*>::construct( ) at
/usr/include/c++/4.0.2/ext/mt_allocator.h:585 0x0804ab8d
20 std::vector<BlockData*, std::allocator<BlockData*> >::push_back()
at /usr/include/c++/4.0.2/bits/stl_vector.h:606 0x0804b6d0
19 std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > >::operator=() at
/usr/include/c++/4.0.2/bits/stl_iterator.h:364 0x080560b1
18 std::__copy<false,
std::random_access_iterator_tag>::copy<BlockData* const*,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:285 0x080560ef
17 std::__copy_aux<BlockData* const*,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:317 0x08056143
16 std::__copy_normal<true,
false>::copy_n<__gnu_cxx::__normal_iterator<BlockD ata* const*,
std::vector<BlockData*, std::allocator<BlockData*> > >,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:335 0x08056191
15 std::copy<__gnu_cxx::__normal_iterator<BlockData* const*,
std::vector<BlockData*, std::allocator<BlockData*> > >,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:387 0x080561ce
14 copyAll<std::vector<BlockData*, std::allocator<BlockData*> > >() at
.../Utils.h:222 0x080609cc
13 DeviantBlockGrouper::handleKey() at ../DeviantBlockGrouper.cpp:132
0x0807fcc1
12 DeviantBlockGrouper::handlegroup() at ../DeviantBlockGrouper.cpp:66
0x0807fe47
11 BlockGrouper::do_group() at ../BlockGrouper.cpp:35 0x08056237
10 boost::lambda::function_adaptor<void() at
/usr/include/boost/lambda/detail/function_adaptors.hpp:346 0x080576fc
9 boost::lambda::function_action<5,
boost::lambda::detail::unspecified>::apply<void, void() at
/usr/include/boost/lambda/detail/actions.hpp:114 0x08057727
8 boost::lambda::lambda_functor_base<boost::lambda:: action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>
, boost::tuples::tuple<void() at /usr/include/boost/lambda/detail/lambda_functor_base.hpp:461 0x08058369 7
boost::lambda::lambda_functor<boost::lambda::lambd a_functor_base<boost::lambda::action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>, boost::tuples::tuple<void() at /usr/include/boost/lambda/detail/lambda_functors.hpp:148 0x08058398 6 std::for_each<__gnu_cxx::__normal_iterator<Pattern Matcher**,
std::vector<PatternMatcher*, std::allocator<PatternMatcher*> > >,
boost::lambda::lambda_functor<boost::lambda::lambd a_functor_base<boost::lambda::action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>, boost::tuples::tuple<void() at /usr/include/c++/4.0.2/bits/stl_algo.h:158 0x080583c1

Any idea is appreciated.

Mar 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I think I resolve my problem. Sorry for the inconvince.

sa***************@gmail.com wrote:
Hi,

I wrote a template to use copy() algorithm, called copyAll:
template<class T>
void copyAll(const T& src , T& dest ) {
copy (src.begin(), src.end(), back_inserter(dest));
}

but when I call it, I get a segmentation fault:
Thread [0] (Suspended: Signal 'SIGSEGV' received. Description:
Segmentation fault.)
21 __gnu_cxx::__mt_alloc_base<BlockData*>::construct( ) at
/usr/include/c++/4.0.2/ext/mt_allocator.h:585 0x0804ab8d
20 std::vector<BlockData*, std::allocator<BlockData*> >::push_back()
at /usr/include/c++/4.0.2/bits/stl_vector.h:606 0x0804b6d0
19 std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > >::operator=() at
/usr/include/c++/4.0.2/bits/stl_iterator.h:364 0x080560b1
18 std::__copy<false,
std::random_access_iterator_tag>::copy<BlockData* const*,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:285 0x080560ef
17 std::__copy_aux<BlockData* const*,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:317 0x08056143
16 std::__copy_normal<true,
false>::copy_n<__gnu_cxx::__normal_iterator<BlockD ata* const*,
std::vector<BlockData*, std::allocator<BlockData*> > >,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:335 0x08056191
15 std::copy<__gnu_cxx::__normal_iterator<BlockData* const*,
std::vector<BlockData*, std::allocator<BlockData*> > >,
std::back_insert_iterator<std::vector<BlockData*,
std::allocator<BlockData*> > > >() at
/usr/include/c++/4.0.2/bits/stl_algobase.h:387 0x080561ce
14 copyAll<std::vector<BlockData*, std::allocator<BlockData*> > >() at
../Utils.h:222 0x080609cc
13 DeviantBlockGrouper::handleKey() at ../DeviantBlockGrouper.cpp:132
0x0807fcc1
12 DeviantBlockGrouper::handlegroup() at ../DeviantBlockGrouper.cpp:66
0x0807fe47
11 BlockGrouper::do_group() at ../BlockGrouper.cpp:35 0x08056237
10 boost::lambda::function_adaptor<void() at
/usr/include/boost/lambda/detail/function_adaptors.hpp:346 0x080576fc
9 boost::lambda::function_action<5,
boost::lambda::detail::unspecified>::apply<void, void() at
/usr/include/boost/lambda/detail/actions.hpp:114 0x08057727
8 boost::lambda::lambda_functor_base<boost::lambda:: action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>
, boost::tuples::tuple<void() at /usr/include/boost/lambda/detail/lambda_functor_base.hpp:461 0x08058369

7
boost::lambda::lambda_functor<boost::lambda::lambd a_functor_base<boost::lambda::action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>
, boost::tuples::tuple<void() at /usr/include/boost/lambda/detail/lambda_functors.hpp:148 0x08058398

6 std::for_each<__gnu_cxx::__normal_iterator<Pattern Matcher**,
std::vector<PatternMatcher*, std::allocator<PatternMatcher*> > >,
boost::lambda::lambda_functor<boost::lambda::lambd a_functor_base<boost::lambda::action<5,
boost::lambda::function_action<5, boost::lambda::detail::unspecified>
, boost::tuples::tuple<void() at /usr/include/c++/4.0.2/bits/stl_algo.h:158 0x080583c1

Any idea is appreciated.


Mar 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.