Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Problem when using PtHold(): (6 Items)
   
Problem when using PtHold()  
I'm developing a graphical user interface software using PhAB.

I made some simple program. 
It's function is like this:  button click -> just call PtHold() 

on_button_click()
{
   PtHold();
}
It works well.


But I changed it like this: button click -> send event to server -> receive response from server -> call PtHold()

regist_receive(&receive_from_server);

on_button_click()
{
   send_to_server();
}

receive_from_server()
{
   PtHold();
}

In this case program causes memory fault every time. (SIGSEGV)
It is same for PtRelease() too.

As I know PtHold() just increases count. I guest it's implementation would be simple.
So I can not image why it causes memory fault. It is so weird.
Anybody can explain about this phenomenon?
RE: Problem when using PtHold()  
How do you receive the message?  Is your code multithreaded?  Could I see a stack trace from a core file?

What are you trying to achieve by calling PtHold() without (as it seems) calling PtRelease()?  The purpose of PtHold() 
it to prevent widgets from redrawing themselves multiple times when you're making multiple changes to them, and the 
intended use is that you call PtHold(), then make your changes to widgets, and then making a matching call to 
PtRelease().  Yes, PtHold() "just" increments a counter, but it has to find the counter first (and that's probably where
 it crashes for you) and there are quite a few pieces of code that the counter affects.  The expectation is that you 
should have a matching PtRelease() (in the same thread) for every PtHold() before you return to the event-processing 
loop, and that you will either not do anything blocking in between, use one of Photon's "modal" mechanisms to do the 
blocking, or call PtFlush() before blocking, to ensure that the widgets redraw themselves according to their current 
state before you block.


> -----Original Message-----
> From: Aram Kim [mailto:community-noreply@qnx.com]
> Sent: July-09-14 8:11 PM
> To: photon-graphics
> Subject: Problem when using PtHold()
> 
> I'm developing a graphical user interface software using PhAB.
> 
> I made some simple program.
> It's function is like this:  button click -> just call PtHold()
> 
> on_button_click()
> {
>    PtHold();
> }
> It works well.
> 
> 
> But I changed it like this: button click -> send event to server -> receive
> response from server -> call PtHold()
> 
> regist_receive(&receive_from_server);
> 
> on_button_click()
> {
>    send_to_server();
> }
> 
> receive_from_server()
> {
>    PtHold();
> }
> 
> In this case program causes memory fault every time. (SIGSEGV) It is same
> for PtRelease() too.
> 
> As I know PtHold() just increases count. I guest it's implementation would be
> simple.
> So I can not image why it causes memory fault. It is so weird.
> Anybody can explain about this phenomenon?
> 
> 
> 
> _______________________________________________
> 
> Photon microGUI
> http://community.qnx.com/sf/go/post111007
> To cancel your subscription to this discussion, please e-mail photon-graphics-
> unsubscribe@community.qnx.com
Re: RE: Problem when using PtHold()  
Thank your for your answer.

Unfortunately send/receiver messages are done by 3rd party library and it doesn't use multi-thread.
The library works as like ping service. Just receives message and sends it again.

And actually I used other functions which contains PtHold().
Real source is like this:

	PtClearWidget(displayPane_tp);
	ApCreateModule(pLink, displayPane_tp, NULL);
	PtReRealizeWidget(displayPane_tp);

And according to the stack trace my software died when calling PtHold() or PtRelease().
So I think pairs of PtHold() and PtRelease() call is not a problem.

Thanks again to your help.
RE: RE: Problem when using PtHold()  
No, I didn't mean to suggest that the crashes are caused by the fact that your PtHold() calls aren't paired with 
PtRelease() calls -- apologies if it sounded that way.  The only reason I asked about that was because I was curious 
what those unpaired calls were meant to achieve, and whether there might be a more "proper" way to achieve it.  That 
curiosity was not directly related to the crashes.

PtHold() is a simple function.  The only two situations that can cause it to crash (other than general memory 
corruption) are when you call it without initializing the widget library first (via PtInit() or the PhAB equivalent) or 
when you call it without holding the library lock (i.e. after calling PtLeave() or without calling PtEnter() where 
appropriate).  That's why I asked about threads and stack traces.

> -----Original Message-----
> From: Aram Kim [mailto:community-noreply@qnx.com]
> Sent: July-09-14 8:56 PM
> To: photon-graphics
> Subject: Re: RE: Problem when using PtHold()
> 
> Thank your for your answer.
> 
> Unfortunately send/receiver messages are done by 3rd party library and it
> doesn't use multi-thread.
> The library works as like ping service. Just receives message and sends it
> again.
> 
> And actually I used other functions which contains PtHold().
> Real source is like this:
> 
> 	PtClearWidget(displayPane_tp);
> 	ApCreateModule(pLink, displayPane_tp, NULL);
> 	PtReRealizeWidget(displayPane_tp);
> 
> And according to the stack trace my software died when calling PtHold() or
> PtRelease().
> So I think pairs of PtHold() and PtRelease() call is not a problem.
> 
> Thanks again to your help.
> 
> 
> 
> 
> _______________________________________________
> 
> Photon microGUI
> http://community.qnx.com/sf/go/post111009
> To cancel your subscription to this discussion, please e-mail photon-graphics-
> unsubscribe@community.qnx.com
Re: RE: RE: Problem when using PtHold()  
Thanks you again.

I'd search more about PtInit(), PtEnter(), PtLeave(). Thanks you.

Stack trace is like this:

(gdb) bt
#0 0xb8330c25 in PtHold()
   from /usr/qnx650/target/qnx6/x86/usr/lib/libph.so.3
#1 0x08053fa3 in receiveGMC()
#2 0xb83fd857 in ReadData() from gmc_client_qnx.so
#3 0xb83fde15 in ReadServer() from gmc_client_qnx.so
#4 0xb0320070 in ?? () from /usr/qnx650/target/qnx6/x86/lib/libc.so.3
(gdb)

receiveGMC(), ReadData(), ReadServer() are 3rd party library functions.
Unfortunately we don't have their debug possible library of GMS client, it is difficult to watch inside of them.
RE: RE: RE: Problem when using PtHold()  
You mentioned that this process is single-threaded.  What is this 3rd party app relation to Photon?  How is it called 
from Photon's event loop?  Is it via some sort of callbacks (including workprocs or input procs)?  The stack trace shows
 that ReadServer() is called from something in libc -- is that correct?  I assume you're calling PtHold() because this 
process has widgets; have some widgets already been created at the point where it crashes?  Or is there a chance that 
the 3rd party lib somehow manages to call your PtHold() before you have managed to initialize your Photon UI?

> -----Original Message-----
> From: Aram Kim [mailto:community-noreply@qnx.com]
> Sent: Thursday, July 10, 2014 12:31 AM
> To: photon-graphics
> Subject: Re: RE: RE: Problem when using PtHold()
> 
> Thanks you again.
> 
> I'd search more about PtInit(), PtEnter(), PtLeave(). Thanks you.
> 
> Stack trace is like this:
> 
> (gdb) bt
> #0 0xb8330c25 in PtHold()
>    from /usr/qnx650/target/qnx6/x86/usr/lib/libph.so.3
> #1 0x08053fa3 in receiveGMC()
> #2 0xb83fd857 in ReadData() from gmc_client_qnx.so
> #3 0xb83fde15 in ReadServer() from gmc_client_qnx.so
> #4 0xb0320070 in ?? () from /usr/qnx650/target/qnx6/x86/lib/libc.so.3
> (gdb)
> 
> receiveGMC(), ReadData(), ReadServer() are 3rd party library functions.
> Unfortunately we don't have their debug possible library of GMS client, it is
> difficult to watch inside of them.
> 
> 
> 
> _______________________________________________
> 
> Photon microGUI
> http://community.qnx.com/sf/go/post111011
> To cancel your subscription to this discussion, please e-mail photon-graphics-
> unsubscribe@community.qnx.com