Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
borceg
Posts: 671
Registered: ‎03-21-2012
My Device: BlackBerry PlayBook 16GB

Re: How to hunt down a segfault?

Try hard-coding this->formula = "whatever"; just for test. If that fails, something is wrong with the libs.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to hunt down a segfault?

The problem is not in DataServiceFormula::setFormula's implementation (I am 99% sure)

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to hunt down a segfault?


borceg wrote:
Try hard-coding this->formula = "whatever"; just for test. If that fails, something is wrong with the libs.

Good idea.

first attempt: pass a fixed string

dsFormula->setFormula("c1");

 no change.

second attempt: change the setter (i renamed the parameter)

void DataServiceFormula::setFormula(QString aformula) {
	formula = "c1";
	//this->formula = formula;
}

 no change, still a segfault.

 

When i comment out the whole function it runs:

void DataServiceFormula::setFormula(QString aformula) {
	//formula = "c1";
	//this->formula = formula;
}

Now i set a breakpoint in there, i get this:

debug.png

 

Doesn't this mean the object is there?

But when i try to access it with qDebug() << "this: " << this; i get a segfault again.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to hunt down a segfault?

What makes you think that 'the object is there'?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to hunt down a segfault?

the value column does not say 0x0, but i have to admit, its just a guess.
Still, the debugger enters the set method and executes code there, would it do that if the object was not existing?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to hunt down a segfault?

C does not check on pointers. When a variable is created there is no guarantee that it'll be initialized with zero. When an object is destroyed then there is no guarantee that poniter vairable that was pointing to this object will be 'nullled'

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to hunt down a segfault?

ok. Why would my object be destroyed? I assumed that an object i create with "new" exists until i call its destructor or call delete/deletelater on the pointer.

Can I check "on pointer"?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to hunt down a segfault?

it might go out of visibility... it is impossible to help you without seeing more source code, that is why I asked for it -)

You can check on pointers.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to hunt down a segfault?

Could the issue be related to not initializing the pointer with NULL?
Basically i assume that getEnabledFormula returns NULL, but maybe that is not correct?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: How to hunt down a segfault?

In my opinion the issue is you are trying to access non existent object via pointer. It does not really matter whether this pointer = NULL or anything else.