![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
SIGSEGV from std::~basic_string
Hello,
I am having a problem with this section of code. for (int a = 0; a < old_d.size(); a++)
{
d_temp.push_back(old_d.at(a));
boogie temp;
temp.boogie_(old_d);
od_frequency.push_back(temp);
}The class boogie looks like this: class boogie{
public:
frequency_ f;
lo_four lf;
derivitive_ d;
void boogie_(vector<drawing> foo);
};Class drawing looks like this class drawing{
public:
string date;
int tic[6];
int PP;
};#0 0x00ad0e9a in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string () from /usr/lib/libstdc++.so.6 #1 0x0804a93f in drawing::~drawing () #2 0x0804d03f in std::_Destroy<drawing> () #3 0x0804ca17 in std::__destroy_aux<drawing*> () #4 0x0804bddc in std::_Destroy<drawing*> () #5 0x0804ade6 in std::vector<drawing, std::allocator<drawing> >::~vector () #6 0x0804a456 in main () When I change the code inside main() to read exactly as it would in temp.boogie_ (adjusting for class memeber names and stuff) I don't have any problems there, however I do have a SIGSEG error that is backtraced as follows #0 0x0076f3dc in memcpy () from /lib/tls/libc.so.6 #1 0x0804c08a in std::_Construct<boogie, boogie> () #2 0x0804b08d in std::vector<boogie, std::allocator<boogie> >::push_back () #3 0x0804a5d9 in main () This can only occur when I push.back the vector<boogie>od_frequency. Any sugestions, thanks. Milt |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
Can you attach the entire source, so we can try it out, or is it too big?
It is possible that your heap is being corrupted before this point. |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
Quote:
Here is the code that applies to boogie (essentially the new stuff I've programed). N is defined as const int N = 64. The function four1 is an external function that I know works. And Number is typedef float. #include <string>
#include <fstream>
#include "fft.cpp"
using namespace std;
const int WHITE = 55;
const int RED = 42;
class drawing{
public:
string date;
int tic[6];
int PP;
};
class lo_four{
public:
Number wdata[2*N];
Number rdata[2*N];
void fft(int w[WHITE+1], int r[RED+1], int isign);
void fft(Number w[WHITE+1], Number r[RED+1], int isign);
void print_four(ofstream &wout, ofstream &rout);
};
class frequency_{
public:
int w[WHITE+1];
int r[RED+1];
void frequency(vector<drawing> p);
void print_frequency(ofstream &out);
};
class derivitive_{
public:
Number dwdata[2*N];
Number drdata[2*N];
void derivitive(Number wdata[2*N], Number rdata[2*N]);
void derivitive(lo_four curr, lo_four pre);
void print_derivitive(ofstream &wout, ofstream &rout);
};
void lo_four::fft(int w[WHITE+1], int r[RED+1], int isign)
{
for (int a = 0; a < 2*N; a++)
{
if (a < WHITE+1)
{wdata[a]=w[a];}
else
{wdata[a]=0;}
if (a < RED+1)
{rdata[a]=r[a];}
else
{rdata[a]=0;}
}
four1(wdata,N,isign);
four1(rdata,N,isign);
}
void lo_four::fft(Number w[WHITE+1], Number r[RED+1], int isign)
{
for (int a = 0; a < 2*N; a++)
{
if (a < WHITE+1)
{wdata[a]=w[a];}
else
{wdata[a]=0;}
if (a < RED+1)
{rdata[a]=r[a];}
else
{rdata[a]=0;}
}
four1(wdata,N,isign);
four1(rdata,N,isign);
}
void lo_four::print_four(ofstream &wout, ofstream &rout)
{
for (int a = 0; a < N; a++)
{
wout << wdata[a] << endl;
rout << rdata[a] << endl;
}
return;
}
void frequency_::frequency(vector<drawing> p)
{
for (int z = 0; z < WHITE+1; z++)
{
w[z]=0;
if (z < RED+1)
{r[z]=0;}
}
for (int a = 0; a < p.size(); a++)
{
for (int b = 0; b < 5; b++)
{
w[p.at(a).tic[b]]++;
}
r[p.at(a).tic[5]]++;
}
return;
}
void frequency_::print_frequency(ofstream &out)
{
out << endl;
out << "-------------------------------------------" << endl;
out << " FREQUENCY " << endl;
out << "-------------------------------------------" << endl;
out << "White:" << endl;
for (int a = 1; a < WHITE+1; a++)
{
out << a << ": " << w[a] << "\t";
if (!a%10)
{out << endl;}
}
for (int b = 1; b < RED+1; b++)
{
out << b << ": " << r[b] << "\t";
if (!b%10)
{out << endl;}
}
return;
}
void derivitive_::derivitive(Number wdata[2*N], Number rdata[2*N])
{//gets the difference between real & imag four data points
dwdata[0] = 0;
drdata[0] = 0;
for (int a = 1; a < 2*N; a++)
{
dwdata[2*a] = wdata[2*a] - wdata[2*(a-1)];
dwdata[2*a+1] = wdata[2*a+1] - wdata[2*(a-1)+1];
drdata[2*a] = rdata[2*a] - rdata[2*(a-1)];
drdata[2*a+1] = rdata[2*a+1] - rdata[2*(a-1)+1];
}
return;
}
void derivitive_::derivitive(lo_four curr, lo_four pre)
{//gets the differenct between two separate four data points
for (int a = 0; a < 2*N; a++)
{
dwdata[a] = curr.wdata[a] - pre.wdata[a];
drdata[a] = curr.rdata[a] - pre.rdata[a];
}
return;
}
void derivitive_::print_derivitive(ofstream &wout, ofstream &rout)
{
for (int a = 0; a < N; a++)
{
wout << dwdata[2*N] << endl;
rout << drdata[2*N] << endl;
}
return;
}I hope this added info clarifies things. Thanks again. |
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
I found my problem. Thanks for your help. The error lies in derivitive(Number*, Number*); the loop should be N not 2*N. Thanks again.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|