Reply
Thread Tools
Posts: 4 | Thanked: 0 times | Joined on Nov 2010
#1
So I'm actually having some issues with this test app I've done under PR1.3. Compiled it against Qt 4.7.0 and Qt Mobility 1.0.2 with MADDE 0.7.48 from Nokia Qt SDK.

But the thing is that for some reason I always end up getting a segmentation fault with it. It always takes a while like 10-20mins for it to crash. And I was hoping some people could help me find out what's wrong..

And here's the source code for it..

qtm.pro
Code:
TEMPLATE = app
CONFIG += mobility
MOBILITY = messaging
SOURCES += qtm.cpp
qtm.cpp
Code:
#include <QtGui>
#include <QMessageManager>
using namespace QtMobility;

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qDebug() << "QT_VERSION_STR: " <<  QT_VERSION_STR;
    qDebug() << "QTM_VERSION_STR: " <<  QTM_VERSION_STR;

    QLabel *l = new QLabel();
    QMessageManager manager;
    QMessageIdList list = manager.queryMessages();
    int count = list.count();
    l->setText("Total: " + QString::number(count));
    l->show();

    app.exec();
}

Last edited by johnson; 2010-11-05 at 17:22.
 
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#2
Put cout/printf in between each line to find out which line segfaults.
It may be that the qtmobility api can be used only once your app.exec has started. So a QTimer handler might be the thing to do.

Also: Use the asynchronous API in qtmobility.
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 
Posts: 4 | Thanked: 0 times | Joined on Nov 2010
#3
I played around with this a while, but still getting always a segmentation fault. This is how the code looks at the moment..

Anywone else getting the segmentation fault or is it just me? Remember it takes quite a while to get it. And I think the problem is Qt Mobility.

qtm.pro
Code:
TEMPLATE = app

CONFIG += mobility
MOBILITY = messaging

SOURCES += main.cpp qtm.cpp
HEADERS += qtm.h
main.cpp
Code:
#include <QApplication>

#include "qtm.h"

int main(int argc, char *argv[])
{
    qDebug() <<  "QT_VERSION_STR: " <<  QT_VERSION_STR;
    qDebug() <<  "QTM_VERSION_STR: " <<  QTM_VERSION_STR;

    QApplication app(argc, argv);

    Qtm m;
    QTimer::singleShot(5000, &m, SLOT(getMessages()));
    m.show();

    return app.exec();
}
qtm.cpp
Code:
#include <QtGui>
#include <QMessageService>

#include "qtm.h"

using namespace QtMobility;

Qtm::Qtm()
{
    connect(&service, SIGNAL(messagesFound(QMessageIdList)), this, SLOT(messagesFound(QMessageIdList)));

    setText("Updating..");
}

void Qtm::getMessages()
{
    service.queryMessages();
}

void Qtm::messagesFound(const QMessageIdList &ids)
{
    list << ids;
    setText("Total: " + QString::number(list.count()));
}
qtm.h
Code:
#ifndef QTM_H
#define QTM_H

#include <QtGui>
#include <QMessageService>

using namespace QtMobility;

class Qtm : public QLabel
{
    Q_OBJECT

public:
    Qtm();
 
private slots:
    void messagesFound(const QMessageIdList &ids);
    void getMessages();

private:
    QMessageService service;
    QMessageIdList list;

};

#endif

Last edited by johnson; 2010-11-06 at 23:21.
 
Posts: 44 | Thanked: 73 times | Joined on Dec 2009 @ Freiburg, Germany
#4
What do you mean with "10-20 mins"? Does it mean you start the program, it shows the number of messages and then stays idle for 15 mins before it crashes?
 
Posts: 4 | Thanked: 0 times | Joined on Nov 2010
#5
Yes. I shows the amount of messages ok and everything seems to be working ok but then after a while idling it crashes.

Feel free to compile that yourself and try out.

Here's the gdb output..
Code:
(gdb) run
Starting program: /home/developer/madde/qtm 
QT_VERSION_STR:  4.7.0 
QTM_VERSION_STR:  1.0.2 
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
sync eventloop exit 
ModestEngine::ModestEngine Starting to initialize 
ModestEngine::ModestEngine Connecting to Modest DBus Interface 
ModestEngine::ModestEngine Connected to Modest DBus Interface 
ModestEngine::ModestEngine Connecting to Qt Mobility Modest Plugin DBus Interface 
ModestEngine::ModestEngine Connected to Qt Mobility Modest Plugin DBus Interface 
ModestEngine::ModestEngine Initialized successfully
and after a while..
Code:
Program received signal SIGSEGV, Segmentation fault.
0x411f94d4 in strlen () from /lib/libc.so.6
0x411f94d4 <strlen+4>:  ldr     r2, [r1], #4
and backtrace..
Code:
(gdb) bt
#0  0x411f94d4 in strlen () from /lib/libc.so.6
#1  0x4009630c in QtMobility::ModestEngine::accountEmailProtocolAsString(QtMobility::QMessageAccountId const&) const () from /usr/lib/libQtMessaging.so.1
#2  0x4009a04c in QtMobility::ModestEngine::folderUpdatedSlot(QDBusMessage) ()
   from /usr/lib/libQtMessaging.so.1
#3  0x400aa344 in QtMobility::ModestEngine::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQtMessaging.so.1
#4  0x40c3e5a4 in QDBusConnectionPrivate::deliverCall(QObject*, int, QDBusMessage const&, QList<int> const&, int) () from /usr/lib/libQtDBus.so.4
#5  0x40c4e78c in ?? () from /usr/lib/libQtDBus.so.4
#6  0x40c4e78c in ?? () from /usr/lib/libQtDBus.so.4
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Last edited by johnson; 2010-11-07 at 01:09.
 
Posts: 44 | Thanked: 73 times | Joined on Dec 2009 @ Freiburg, Germany
#6
Did you try running it on Qt Simulator?

I believe this is worth a bug report. There are already at least 2 bug reports in Qt Bug Tracker which are related to networking and multithreading in Maemo 5 PR 1.3 (Qt 4.7.0). Maybe your one is related to that problem as well or it is a new. But your code looks good and it should not crash when idle.
 
Posts: 121 | Thanked: 53 times | Joined on Aug 2006 @ Alexandria, VA, USA
#7
I think you're running out of memory. Look at what you do to list in your slot
Code:
void messagesFound(const QMessageIdList &ids)
. You add the contents of ids to list. Unless you empty list once in a while, you will eventually use all available memory.
 
Posts: 4 | Thanked: 0 times | Joined on Nov 2010
#8
But as you can see from the source it's only running once. Anyway I still modified the code to look like this..

Code:
void Qtm::messagesFound(const QMessageIdList &ids)
{
    list << ids;
    setText("Total: " + QString::number(list.count()));
    list = QMessageIdList();
}
No help. Still crashing. Has anyone else tried compiling and running the code? Am I the only one getting the segmentation fault?

Last edited by johnson; 2010-11-07 at 22:22.
 
Posts: 5 | Thanked: 5 times | Joined on Nov 2010
#9
Perhaps this problem is related to the Messaging API. I'm experiencing similar problems, when simply trying to count sms messages with this API. Everything works fine, when running the code in the simulator, but as soon as I deploy it to the device and run the code, which contains the access to the Messaging API, I get the segmentation fault.

There is also a thread on the Nokia forum, which seems to describe a similar problem:

http://discussion.forum.nokia.com/fo...entation-fault..

But no solution, so far.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#10
Just tried this simple qtmobility application:
Code:
#include <QtGui/QApplication>
#include <QMessageManager>

QTM_USE_NAMESPACE

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMessageManager manager;
    QMessageFilter filter = QMessageFilter::byType(QMessage::Sms);
    QMessageIdList messageIds = manager.queryMessages(filter, QMessageSortOrder(), 10);

    return a.exec();
}
And let it run for half an hour - no crash. Then I realized I don't
have any mail accounts configured, because I reflashed my
device some days ago. So, I configured a mail account and
set update interval at 5 min.
What do you think happend?
The app crashed after 5 minutes.
Set the mail update interval to 10 minutes and ...
The app crashed after 10 minutes : -)

nicolai
 

The Following User Says Thank You to nicolai For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 17:44.