Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - PtAppAddCallback Issue: (6 Items)
   
PtAppAddCallback Issue  
My application seg faults when I add the following code:

I am making the following call in the setup function of my main window.

PtAppAddCallback(Pt_CB_FILTER, AppEventFilter, NULL);

The prototype for AppEventFilter is:

int AppEventFilter(void* pData, PtCallbackInfo_t* pCbInfo);

The attached file shows the call stack and the Setup function where the PtAppAddCallback() is called.

Thanks for any help.

Kendall
Attachment: Image PtAppAddCallback.JPG 199.83 KB
Re: PtAppAddCallback Issue  
More information:

The application seg faults while it is starting up and before any windows are displayed.

Thanks,
Kendall
Re: PtAppAddCallback Issue  
> My application seg faults when I add the following code:
> 
> I am making the following call in the setup function of my main window.
> 
> PtAppAddCallback(Pt_CB_FILTER, AppEventFilter, NULL);
> 
> The prototype for AppEventFilter is:
> 
> int AppEventFilter(void* pData, PtCallbackInfo_t* pCbInfo);
> 
> The attached file shows the call stack and the Setup function where the 
> PtAppAddCallback() is called.
> 
> Thanks for any help.
> 

Don't know if that could help, but I just had a case of PtAppCreatePulse doing a SIGSEGV, I traced it to PtInit being 
called in a thread that was terminated before the PtAppCreatedPulse was called, note that PtInit was being called again 
as the second thread that did the PtAppCreatePulse was called but that doesn't seems photon friendly.

> Kendall


Re: PtAppAddCallback Issue  
> Don't know if that could help, but I just had a case of PtAppCreatePulse doing
>  a SIGSEGV, I traced it to PtInit being called in a thread that was terminated
>  before the PtAppCreatedPulse was called, note that PtInit was being called 
> again as the second thread that did the PtAppCreatePulse was called but that 
> doesn't seems photon friendly.

Did you by any chance forget to PtEnter() before calling PtAppCreatePulse() in the second thread?  This program works 
for me:

#include <stdio.h>
#include <pthread.h>
#include <Pt.h>

static void *thread( void *arg ) {
        if ( PtInit(NULL) ) {
                perror( "PtInit" );
                exit( 1 );
        }
        return NULL;
}

int main( int argc, char **argv ) {
        int err;
        pthread_t tid;
        if ( ( err = pthread_create( &tid, NULL, thread, NULL ) ) != 0 ) {
                fprintf( stderr, "pthread_create: %s\n", strerror(err) );
        }
        pthread_join( tid, NULL );
        PtEnter(NULL);
        printf( "Pulse is %d\n", PtAppCreatePulse( NULL, -1 ) );
        return 0;
}
Re: PtAppAddCallback Issue  
I think the problem is that  PtAppAddCallback() assumes that the callback uses the PtAppCallback_t structure, which is 
not true for the Pt_CB_FILTER callback.  Try using PtAppSetResources() instead.
Re: PtAppAddCallback Issue  
PtAppSetResource() solved the problem

Thank you.
Kendall