472,954 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Segmentation fault in copy algorithm

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
1 3106
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: AMT2K5 | last post by:
Hello guys. I have a function, cleanSpace . I was told from another source that the problem is, is that the function is acting on constant string literal. To fix this I was told to take the...
7
by: silverburgh.meryl | last post by:
Hi, I have a C++ problem which uses STL containers and algorithm and it has a segmentation fault under some condition. Here is a back trace from gdb. Is it possible to tell what is wrong...
1
by: utab | last post by:
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <iterator> using std::cout; using std::vector; using std::string; using std::endl;
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
2
by: tikcireviva | last post by:
Hi Guys, I am not sure what's wrong with my program. When I ran it under the GDB, it shows the following messages , which said that the issue is from stl_list.h. Does anyone know what's...
1
by: jwlkr | last post by:
Hi, I am trying to sort a vector of a user defined type: a class which represents points in cartesian coordinates. The vector of points needs to be sorted according to the value of the...
11
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to...
15
by: Rares Vernica | last post by:
Hello, I have a strange problem. I compile my code with g++ (GCC) 4.1.2. My code runs just fine if I use the -O2 optimization flag. valgrind does not report any memory leak. When I use the...
3
by: jr.freester | last post by:
I have created to classes Matrix and System. System is made up of type matrix. ---------------------------------------------------------------------------------- class Matrix { private: int...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.