entering perl callback handler... my_perl == NULL Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7b55b90 (LWP 28603)] 0xb7b6b1e8 in SWIG_Wrap_callback (event=int, p_data=0xb7b553a0) at ../../../../../..//client/perl/bsa_api_wrap.c:2005 2005 printf("Destruct level : %d...\n", PL_perl_destruct_level); (gdb) where #0 0xb7b6b1e8 in SWIG_Wrap_bsa_disc_callback (event=int, p_data=0xb7b553a0) at ../../../../../../client/perl/bsa_api_wrap.c:2005 #1 0xb7bce6e5 in bsa_mgt_disc_hdlr (p_msg=0xb7bf3aac) at ../../../../../..//client/mgt/bsa_mgt_int.c:63 #2 0xb7bce8ce in callback_task (param=0) at ../../../../../..//client/mgt/bsa_mgt_int.c:159 #3 0xb7ec94fb in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 #4 0xb7e4be5e in clone () from /lib/tls/i686/cmov/libc.so.6 #### void SWIG_Wrap_callback(int event, tMy_MSG *p_data) { printf("entering perl callback handler...\n"); dTHX; /*Not sure this is needed, but doesnt make any difference */ if ( my_perl != NULL ) printf ("my_perl == %ul\n", my_perl); else printf ("my_perl == NULL\n"); /* This line is printed*/ PERL_SET_CONTEXT(my_perl); /* Not sure this is needed, but tried in vain */ printf("dTHX done...\n"); dSP; /* Crashes here */ printf("Destruct level : %d...\n", PL_perl_destruct_level); /* "0" (ZERO) is printed under the scenario where callback invokation works. Does it mean perl is not built correctly per my needs?? */ printf("DSP done...\n"); SV * sv = bsa_perl_disc_callback; if (sv == (SV*)NULL) croak("Internal error...\n"); printf("Preparing to call perl callback...\n"); PUSHMARK(SP); XPUSHs(sv_2mortal(newSViv(event))); printf("newSViv of %d done...\n", event); XPUSHs(SWIG_NewPointerObj(SWIG_as_voidptr(p_data), SWIGTYPE_p_tMy_MSG, SWIG_SHADOW)); printf("newSVsv...\n"); PUTBACK; printf("calling the Perl sub...\n"); /* Call the Perl sub */ call_sv(sv, G_DISCARD); printf("Perl sub completed successfully...\n"); } #### printf("entering perl callback handler...\n"); register PerlInterpreter *my_perl __attribute__((unused)) = ((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))); if ( my_perl != ((void *)0) ) printf ("my_perl == %ul\n", my_perl); else printf ("my_perl == NULL\n"); (void)( { int _eC_; if ((_eC_ = pthread_setspecific((*Perl_Gthr_key_ptr(((void *)0))), (void *)(my_perl)))) Perl_croak_nocontext("panic: pthread_setspecific (%d) [%s:%d]", _eC_, "../../../../../../3rdparty/embedded/brcm/bsa/client/perl/bsa_api_wrap.c", 2005); } ); printf("dTHX done...\n"); register SV **sp = (*Perl_Tstack_sp_ptr(((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))))); printf("Destruct level : %d...\n", (*Perl_Iperl_destruct_level_ptr(((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0)))))))); printf("DSP done...\n"); #### -Dbool=char -fpic -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -isystem /usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DSWIG -g -DMULTIPLICITY -DPERL_IMPLICIT_CONTEXT -DTHREADS_HAVE_PIDS -DUSE_LARGE_FILES -DUSE_PERLIO -DUSE_REENTRANT_API -DBSA_CLIENT #### Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.24-19-server, archname=i486-linux-gnu-thread-multi uname='linux palmer 2.6.24-19-server #1 smp sat jul 12 00:40:01 utc 2008 i68 6 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-f PIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darch lib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendora rch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.8 -Dsitearch=/usr/local/lib/perl/5.8.8 -Dman1dir=/usr/share/man/man1 -Dman3dir=/u sr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man /man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='4.2.3 (Ubuntu 4.2.3-2ubuntu7)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.7.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8 gnulibc_version='2.7' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Jan 14 2009 22:34:36 @INC: /etc/perl /usr/local/lib/perl/5.8.8 :