Z
ZillionDollarSadist
Hello,
I have an initialization function of a class going like this:
==========================
void innode::initAllOutput(set* train, set* test)
{
const int trainSize=train->getMolecules();
nodeValueTrainZ=new double[trainSize];
output=new double*[trainSize];
residual=new double [trainSize];
tmpRec=new double*[trainSize];
for (int i=0;i<trainSize;i++) {
const int localSize=train->getCurrentSize(i);
output=new double[localSize];
tmpRec=new double[localSize]; **** SEGFAULTS HERE
}
const int testSize=test->getMolecules();
nodeValueTestZ=new double[testSize];
toutput=new double*[testSize];
for (int i=0;i<testSize;i++) {
const int localSize=test->getCurrentSize(i);
toutput=new double[localSize];
}
trainOutvals=new double[trainSize];
testOutvals=new double[testSize];
}
=====================
What happens is this: it works of 3 or 4 times in a row, then it
segfaults at ***. The strange thing is that variable localSize should
be something between 12 and 25 (it means the number of nodes in a
graph), and at the segfault time it becomes something like 1061662914,
so I guess such an array breaks the stack.
What to do now? I really can't understand why this happens...
Thanks!
ZDS.
I have an initialization function of a class going like this:
==========================
void innode::initAllOutput(set* train, set* test)
{
const int trainSize=train->getMolecules();
nodeValueTrainZ=new double[trainSize];
output=new double*[trainSize];
residual=new double [trainSize];
tmpRec=new double*[trainSize];
for (int i=0;i<trainSize;i++) {
const int localSize=train->getCurrentSize(i);
output=new double[localSize];
tmpRec=new double[localSize]; **** SEGFAULTS HERE
}
const int testSize=test->getMolecules();
nodeValueTestZ=new double[testSize];
toutput=new double*[testSize];
for (int i=0;i<testSize;i++) {
const int localSize=test->getCurrentSize(i);
toutput=new double[localSize];
}
trainOutvals=new double[trainSize];
testOutvals=new double[testSize];
}
=====================
What happens is this: it works of 3 or 4 times in a row, then it
segfaults at ***. The strange thing is that variable localSize should
be something between 12 and 25 (it means the number of nodes in a
graph), and at the segfault time it becomes something like 1061662914,
so I guess such an array breaks the stack.
What to do now? I really can't understand why this happens...
Thanks!
ZDS.