c++ error only on x86_64

Support for the other architectures (X86_64, s390(x) and PowerPC)
Post Reply
zl2k
Posts: 7
Joined: 2007/01/25 14:53:10

c++ error only on x86_64

Post by zl2k » 2007/01/26 19:11:24

hi,
I have one program runs fine on my i386 Fedora 5 but get the "glibc
detected *** corrupted double-linked list" error on the x86_64 centos 4.4.
Please help me to figure out if it is my program's problem or the
library's problem. The libraries I am using is the boost and stl. The
original program is quite long and I shrink it short and still able to
duplicate the error. Basically, I first create a priority queue and
after several round of pop the queue the error message comes up. The
x86_64 is just installed so the packages there are most current,
comparing to those in the i386 box.

I highly suspect this is a x86_64 related question other than a c++ question. I also asked in c++ group and there is no feedback saying the program is wrong.

Here is the testing part:
-------------------------------------------------
#include
#include "Point2i.h"
#include "myUnit.h"
#include
#include

int main(int, char *[])
{
std::priority_queue,std::vector >, ptr_less > >
priorityQ;
for (int i = 0; i p(new Point2i(i,j));
boost::shared_ptr unit(new myUnit(std::rand(), p, i, j));
priorityQ.push(unit);
}

while (!priorityQ.empty()){
std::coutx = x;
this->y = y;
}
~Point2i();

};

#endif
---------------------------------------------------
#include "Point2i.h"

void Point2i::operator=(const Point2i &right){
this->x = right.x;
this->y = right.y;

}

Point2i::~ Point2i(){}
--------------------------------------------------
#include "myUnit.h"

myUnit::myUnit(const double delta, const shared_ptr& p, const
unsigned short aCount, const unsigned short bCount) {
this->delta = delta;
this->p = p;
this->aCount = aCount;
this->bCount = bCount;

}

myUnit::~myUnit(){
p.~shared_ptr();
}

-----------------------------------------------------
#define MYUNIT_H

#include "Point2i.h"
#include

using namespace boost;

class myUnit {
public:
double delta;
shared_ptr p;
unsigned short aCount, bCount;
myUnit(const double delta, const shared_ptr& p, const
unsigned short aCount, const unsigned short bCount);
~myUnit();
bool operator right.delta;
};

};

template
struct ptr_less{
bool operator()(const shared_ptr & lhs, const
shared_ptr & rhs){
return *lhs < *rhs ;
}
};

#endif
----------------------------------------------------

Here is the result from i386 machine, no error:
9 8
8 7
7 6
6 5
5 4
4 3
3 2
2 1
1 0

Here is the result from x86_64 machine with error:
9 8
8 7
7 6
6 *** glibc detected *** corrupted double-linked list:
0x00000000006d5950 ***
Aborted

Thanks for your help. Have a good weekend.

zl2k

robhancock
Posts: 2
Joined: 2007/03/06 16:47:52

Re: c++ error only on x86_64

Post by robhancock » 2007/03/06 16:53:08

It's almost certainly a problem with your program that happens not to show up on i386. Try running Valgrind on it and see what shows up.

Post Reply

Return to “CentOS 4 - X86_64,s390(x) and PowerPC Support”