[S60] Char - A data abort exception has occurred.
Hi, when i call this funcion: char *res =(char*) bsearch(ssid, ptr, 9704447, 17, comparator); i use a comparator function.
comparator():
Code:
int comparator(const void *a, const void *b)
{
qDebug()<<"comparator()";
const char *aa = (const char *)a, *bb = (const char *)b;
qDebug()<<"1";
for (int i = 0; i < 6; ++i) {
qDebug()<<"2";
qDebug()<<"i:"<<i;
qDebug()<<"i:"<<i<<" aa:"<<aa[i]<<" bb:"<<bb[i];
qDebug()<<"3";
if (aa[i] != bb[i]) {
return aa[i] - bb[i];
}
}
return 0;
}
My aplication crash, it is the debug:
Executable file: 9058 2010-10-25T01:46:47 C:\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb \meoKeyMap.exe
Package: 9380 2010-10-25T01:46:50 C:\Users\Ze\Documents\Qt\meoKeyMap\meoKeyMap.sis
Deploying application to 'Nokia E51 USB (COM4)'...
Copying installation file...
Installing application...
Starting application...
Application running with pid 875.
[Qt Message] comparator()
Process 875, thread 876 stopped at 0x7b95028c: A data abort exception has occurred.
[Qt Message] 1
[Qt Message] 2
[Qt Message] i: 0
Finished.
Re: [S60] Char - A data abort exception has occurred.
What is it exactly that you are trying to do? Since you are using Qt, why not use the facilities it provides? Or at least what std C++ provides (like strings instead of C strings).
Re: [S60] Char - A data abort exception has occurred.
Hi, i change it for qStrings and it works in PC but when i compile in the mobile it crash:
Code:
int comparator(const void *a, const void *b)
{
qDebug()<<"1";
QString aaa
(const_cast<char
*>
(reinterpret_cast<const
char*>
(a
)));
QString bbb
(const_cast<char
*>
(reinterpret_cast<const
char*>
(b
)));
qDebug()<<"2";
for (int i = 0; i < 6; ++i) {
if (aaa.at(i).toAscii() != bbb.at(i).toAscii()) {
// qDebug()<<"diference1:"<<aaa.at(i).toAscii() - bbb.at(i).toAscii();
return aaa.at(i).toAscii() - bbb.at(i).toAscii();
//return aa[i] - bb[i];
}
}
return 0;
}
Executable file: 9064 2010-10-25T11:55:40 C:\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb \meoKeyMap.exe
Package: 9332 2010-10-25T11:55:42 C:\Users\Ze\Documents\Qt\meoKeyMap\meoKeyMap.sis
Deploying application to 'Nokia E51 USB (COM6)'...
Copying installation file...
Installing application...
Starting application...
Application running with pid 1103.
[Qt Message] 1
Process 1103, thread 1104 stopped at 0x7b9e1644: A data abort exception has occurred.
Finished.
A lot of people ask me for a backtrace, do you know how can i get it using qt and the debugger?!
Re: [S60] Char - A data abort exception has occurred.
Why are you using bsearch() in the first place? If you have a sorted array, use qLowerBound(), qUpperBound() or qBinaryFind(). You don't need any custom comparators for that and certainly no C-ish code like this.
Re: [S60] Char - A data abort exception has occurred.
I have a sorted text file not an array. I have a QFile::map():
Code:
uchar
* ptr
= f.
map(0,fileSize,
QFile::NoOptions);
Can i do that with this?!
Re: [S60] Char - A data abort exception has occurred.
Yes, why not? Of course provided each item in the file is of the same size.
Re: [S60] Char - A data abort exception has occurred.
Code:
qBinaryFind(container.begin(), container.end(), value);
But i can't do ptr.begin, can i give him the values? because i already know them!
Re: [S60] Char - A data abort exception has occurred.
Re: [S60] Char - A data abort exception has occurred.
i'm doing that way:
Code:
const char* aa
=reinterpret_cast<const
char*>
(f.
map(0,f.
size(),
QFile::NoOptions));
QList<QByteArray> bla
= QByteArray::fromRawData(aa,f.
size()).
split("\n");
QVector<int>::iterator i = qBinaryFind(bla.begin(),bla.end(),"111111");
it gives me some errors that i can't figure out:
..\binaryFind\mainwindow.cpp:26: error: invalid conversion from 'const char*' to 'char'
..\binaryFind\mainwindow.cpp:26: error: initializing argument 1 of 'QList<QByteArray> QByteArray::split(char) const'
..\binaryFind\mainwindow.cpp:27: error: cannot convert 'QList<QByteArray>::iterator' to 'int*' in initialization
Re: [S60] Char - A data abort exception has occurred.
Well, the code doesn't make any sense (syntactically) so I can't blame the compiler for refusing to build it.
And logically with the above code mapping the file to memory has no sense because you are copying anyway when calling split().
Re: [S60] Char - A data abort exception has occurred.
Can you help doing that job?! I know that i need more background from c/c++.... :s
Re: [S60] Char - A data abort exception has occurred.
Ok, here is a solution that copies the data. If you want to avoid a copy, modify it to suit your needs:
Code:
f.
open(QFile::ReadOnly|QFile
::Text);
Re: [S60] Char - A data abort exception has occurred.
Thanks, i implement the binary seach by my self and use the QFile::seek to go the position i want in the file, and it work great! Thanks for all ;)