Dear my friends...
I am using SuSE 9.1 and Qt 3.2.
I wrote a program. compiled successfully. But it
doesn't run more than 3 minutes. It simply crashed
after around 3 minutes.
I use "ddd" to find where it crashes.
Here is the output of my ddd:
Dump of assembler code for function
_ZNK12QSqlDatabase6isOpenEv:
0x405019f0 :
push %ebp
0x405019f1 :
mov %esp,%ebp
0x405019f3 :
push %ebx
0x405019f4 :
sub $0x4,%esp
0x405019f7 :
mov 0x8(%ebp),%eax
0x405019fa :
call 0x401e0beb <__i686.get_pc_thunk.bx>
0x405019ff :
add $0x2054f5,%ebx
0x40501a05 :
mov 0x28(%eax),%eax
0x40501a08 :
mov (%eax),%eax
0x40501a0a :
mov %eax,(%esp)
0x40501a0d :
call 0x401b8e14 <_init+47544>
0x40501a12 :
pop %ecx
0x40501a13 :
movzbl %al,%eax
0x40501a16 :
pop %ebx
0x40501a17 :
pop %ebp
0x40501a18 :
ret
0x40501a19 :
nop
0x40501a1a :
lea 0x0(%esi),%esi
End of assembler dump.
The error message is :
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 4934)]
0x40501a08 in QSqlDatabase::isOpen () from
/usr/lib/libqt-mt.so.3
I found from ddd the crash happened on this line
"
Current program counter (stopped by signal) :
0x40501a08 : mov
(%eax),%eax
"
Why is it happenned?
Please tell me.
===========
#Here is my code where the crash
bool depanForm::cariappSlot()
{
int sid, cid;
QString applist, pesan;
unsigned int noapp;
//if ( ! db->isOpen() ){
// konekSlot();
//}
if ( !un ){
QString lines;
QFile file( "otentik.txt" );
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
QString line;
//int i = 1;
while ( !stream.atEnd() ) {
line = stream.readLine(); // line of text
excluding '\n'
//printf( "%3d: %s\n", i++, line.latin1()
);
lines += line;
}
file.close();
}
//baca username dan paswordnya
extunpwSlot(lines);
}
QSqlDatabase * db =
QSqlDatabase::addDatabase("QPSQL7", "OTHER");
db->setHostName("192.168.23.1");
db->setDatabaseName("kv");
db->setUserName("postgres");
db->setPassword("honestly");
if ( ! db->open() )
{
db->lastError().showMessage();
return false;
}
QSqlQuery query(db);
QString sqloten = QString("select SalesID from
useraccount where Username='%1' and Password='%1'")
.arg(un)
.arg(pw);
query.prepare(sqloten);
query.exec();
if ( ! query.isActive() ){
query.lastError().showMessage();
return false;
}else{
while ( query.next() ){
sid = query.value(0).toInt();
}
}
appdate = QDate::currentDate();
apptime = QTime::currentTime();
applist = QString("v_applist_%1").arg(un);
sqlcekapp = QString("select noapp, custid from %1
where salesid='%1' and date='%1' and time='%1' and
warned='N' limit 1")
.arg(applist)
.arg(sid)
.arg(appdate.toString("yyyy-MM-dd"))
.arg(apptime.toString("hh:mm:ss"));
QSqlQuery querycekapp(db);
querycekapp.prepare(sqlcekapp);
querycekapp.exec();
if ( ! querycekapp.isActive() ){
querycekapp.lastError().showMessage();
return false;
}
if ( querycekapp.next() ){
noapp = querycekapp.value(0).toInt();
cid = querycekapp.value(1).toInt();
pesan = QString("Sie haben ein Termin mit
Kundennummer : %1")
.arg(cid);
QMessageBox::warning(this, "Achtung !", pesan);
updatewarnedSlot(noapp);
}else{
//if ( ! db->isOpen() ){
// konekSlot();
//}
appdate = QDate::currentDate();
apptime = QTime::currentTime();
sqlcekapp = QString("select noapp, custid from %1
where salesid='%1' and (date<='%1' or ( date = '%1'
and time<='%1' )) and warned='N' limit 1")
.arg(applist)
.arg(sid)
.arg(appdate.toString("yyyy-MM-dd"))
.arg(appdate.toString("yyyy-MM-dd"))
.arg(apptime.toString("hh:mm:ss"));
QSqlQuery querycekapp(db);
querycekapp.prepare(sqlcekapp);
querycekapp.exec();
if ( ! querycekapp.isActive() ){
querycekapp.lastError().showMessage();
return true;
}
if ( querycekapp.next() ){
noapp = querycekapp.value(0).toInt();
cid = querycekapp.value(1).toInt();
pesan = QString("Sie haben ein Termin mit
Kundennummer %1 verpassen")
.arg(cid);
QMessageBox::warning(this, "Achtung !", pesan);
updatewarnedSlot(noapp);
}
}
return true;
}
_______________________________
Do you Yahoo!?
Shop for Back-to-School deals on Yahoo! Shopping.
http://shopping.yahoo.com/backtoschool