PDA

View Full Version : can't find linker symbol for virtual table for `QString::Data' value



sedi
15th August 2012, 13:35
Hi,
my project is quite big (174 files as of now) so I can't really put up the code here, I'll try to provide the essential parts (see below).
Nonetheless I would ask you to help me to understand a runtime error message:


can't find linker symbol for virtual table for `QString::Data' value
found `QString::shared_null' instead

This appears when I instantiate a QObject derived class. There are several QStrings being passed to the object with the construction.

The above error message appears when both of the following facts are given:

One of the QStrings is empty (doesn't matter if I pass an empty String variable, "" or QString("))
I have a breakpoint inside the object

A signal that should be emitted from that QObject is *not* being emitted in case of 1..

I have tried to narrow down the problem, but as of now it seems to be in the very moment of construction.

I thought it was perfectly normal to pass empty Strings - isn't it?

I have cleaned, run qmake, built everything new, restarted QtCreator, erased the -pro-user file - all to no avail.

Any ideas how to hunt down this problem?
I have a tendency of not knowing basic things because I've only started c++/Qt about a year ago.

Header of the abstract class:

class AbstractApp: public QObject
{
Q_OBJECT
public:
AbstractApp(QString passedAppName,
QString kursName,
QString passedRoomId,
MyModel* myModel,
MyRoomModel* passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent);
//and much more

Implementation of the abstract class:

AbstractApp::AbstractApp(QString passedAppName,
QString kursName,
QString passedRoomId,
MyModel* parentModel,
MyRoomModel* passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent)
:QObject(parent)
{
//much
}

Header of a derived class:

class App_Raumbau : public AbstractApp
{
Q_OBJECT
public:
App_Raumbau(QString passedAppName,
QString kursName,
QString passedRoomId,
QVector<TischKlasse*> passedTischVektor,
MyModel* parentModel,
MyRoomModel* passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent);
//and much more

Implementation of a derived class:

App_Raumbau::App_Raumbau(QString passedAppName,
QString kursName,
QString passedRoomId,
QVector<TischKlasse*> passedTischVektor,
MyModel *parentModel,
MyRoomModel *passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent)
:AbstractApp(passedAppName,
kursName,
passedRoomId,
parentModel,
passedRoomModel,
passedSchedModel,
scene,
parent)

{ //much

I can assure the pointers are not the problem - the error message depends on empty strings:

Constructing in mainWindow.cpp (gives error message):

app=new App_Raumbau("Raumbau", "Test", "", this->tischVektor, this->model,this->roomModel, this->schedModel, this->scene, 0);

Constructing in mainWindow.cpp (gives NO error message):

app=new App_Raumbau("Raumbau", "Test", "Test", this->tischVektor, this->model,this->roomModel, this->schedModel, this->scene, 0);

high_flyer
15th August 2012, 14:39
If you have pointer members, make sure they are all initialized, sounds like you have a connect that has a garbage sender pointer.

sedi
15th August 2012, 20:09
Thank you, high_flyer! I've looked into this and I am sure none of the passed pointers are uninitialized and none of the pointers that are members are uninitialized.

[I have to admit that the signal problem was not connected to the above error message - it's probably generally not a good idea to emit a signal from the constructor of a class... sorry for that misleading part - the connection just had not been set up properly.]

Still the problem is - quite odd - :
- Whenever I pass "" as an argument to the constructor I recieve the vtable error message when entering the class
- Without a breakpoint in the class I don't have (or: don't see?) the error message.

I try to understand what the message wants to tell me.


can't find linker symbol for virtual table
So Qt has an internal table to link variables. Is that made for signals & slots? Or is if for debugging purposes only?


for `QString::Data' value
That means: there is a String data to be looked up - but it can't be found


found `QString::shared_null' instead
What the heck? Instead of data it found null - ok. But shared_null?

And another thing[tm]:
When I pass two empty strings I recieve the same error message twice

Yet another addition:
It doesn't change anything when I change the constructor of the derived class to this:


App_Raumbau::App_Raumbau(QString passedAppName,
QString kursName,
QString passedRoomId,
QVector<TischKlasse*> passedTischVektor,
MyModel *parentModel,
MyRoomModel *passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent)
:AbstractApp("dummy",//passedAppName,
"dummy",//kursName,
"dummy",//passedRoomId,
parentModel,
passedRoomModel,
passedSchedModel,
scene,
parent)

{ //much

sedi
15th August 2012, 22:13
I have - by now - pretty much ruled out that it is something inside the constructor that causes the problem. It seems to occur in the very calling.

I could comment out the derived constructor's content entirely - same error message.
I 've cut down the constructor of my abstract class to the bare minimum (see below) - same error message

It is simply invoking the beast with an empty string that causes the problem. As soon as Qt debugger then steps into the App_Raumbau file I am up shit creek.

Here is the minimum constructor of the abstract class (though I think the problem shouldn't be here, see the "dummys" in my last post):

AbstractApp::AbstractApp(QString passedAppName,
QString kursName,
QString passedRoomId,
MyModel* parentModel,
MyRoomModel* passedRoomModel,
MySchedModel* passedSchedModel,
ClassroomGraphicsScene *scene,
QObject *parent)
:QObject(parent)
{
this->parentObject=parent;
this->parentScene=scene;
this->model=parentModel;
this->roomModel=passedRoomModel;
this->schedModel=passedSchedModel;
this->nameString=passedAppName;
this->currentKursName=kursName;
this->currentRoomId=passedRoomId;


helpButton=new HelperButton(model->getMetaDBDirectData("PultIconGröße").toInt()*model->getMetaDBDirectData("ZoomFaktor").toFloat(),this->model,0,parentScene);
this->linksButton = new ButtonItem(model->getMetaDBDirectData("ButtonGröße").toInt()*this->model->getZoomFactor(), model, 0, this->parentScene);
this->rechtsButton = new ButtonItem(model->getMetaDBDirectData("ButtonGröße").toInt()*this->model->getZoomFactor(), model, 0, this->parentScene);
}

high_flyer
16th August 2012, 10:04
I have - by now - pretty much ruled out that it is something inside the constructor that causes the problem. It seems to occur in the very calling.
How did you check that?

Try the following:
make your QString parameters pointers, and initialize them before you call the constructor, and pass the initialized pointers.


I try to understand what the message wants to tell me.
It says it trying to to resolve a dynamic type by looking at the virtual call table and it can't find what it is looking for.
http://en.wikipedia.org/wiki/Virtual_method_table
This usually may indicate bad initialization of a used polymorphic object.

can you show the implementation of your AbstractApp constructor, specifically the member initialization?

amleto
16th August 2012, 22:46
what compiler and system are you using?
How did you build Qt? What compiler and version did you use to build Qt?

sedi
17th August 2012, 20:35
Hm. It's been quite some time since then. I think I've just downloaded the installer.

I work on a Win7 64bit system

Creator's about states:
Qt Creator 2.0.1
Based on Qt 4.7.0 (32 bit)
Built Aug 24 2010
Revision 97d831e3de

The compiler is mingw32