RE: [tcljava-user] Tcl Extension
Brought to you by:
mdejong
From: Pierce, G. <Gre...@ls...> - 2006-02-09 17:08:32
|
=20 Hi Mo, I think I found my problem. I wasn't using the libtclstubs8.4.a library I was using the libtcl8.4.a library while compiling my extension. Also, I wasn't including the -DUSE_TCL_STUBS while compiling. My problems seem to have gone away (for now). I need to do some further testing, but I think my problem has been solved. This is a good lesson since my extension worked fine with a basic tcl interperter (i.e. tclsh). However, as soon as I tried to use it in TclBlend I had problems. Greg > -----Original Message----- > From: tcl...@li...=20 > [mailto:tcl...@li...] On Behalf=20 > Of Pierce, Greg > Sent: Wednesday, February 08, 2006 2:05 PM > To: tcl...@li... > Subject: RE: [tcljava-user] Tcl Extension >=20 > Hi Mo DeJong, >=20 > I can get my simple Tcl Extension to work in TclBlend if I do the > following: >=20 > =20 > Interp *iPtr =3D (Interp *) interp; > Tcl_IncrRefCount(iPtr->objResultPtr); >=20 > Tcl_WrongNumArgs(interp, 0, argv, "?pattern?"); >=20 > The above Tcl_WrongNumArgs command will fail with the alloc error if I > don't > Increment the ref count for objResultPtr of the interpreter. >=20 > Does anyone know why I would have to do this? Why is the data=20 > in the Tcl > Interpreter getting messed up? Obviously, I don't want to have to do > this > so I need to figure out why I need to. >=20 > By the way, my Tcl Extension only has one command and the only thing > that > command does it call Tcl_WrongNumArgs. This is as basic Tcl=20 > Extension as > you can get and should work in TclBlend. >=20 > Greg >=20 >=20 > > -----Original Message----- > > From: tcl...@li...=20 > > [mailto:tcl...@li...] On Behalf=20 > > Of Mo DeJong > > Sent: Monday, February 06, 2006 9:27 PM > > To: tcl...@li... > > Subject: Re: [tcljava-user] Tcl Extension > >=20 > > On Mon, 6 Feb 2006 13:40:10 -0700 > > "Pierce, Greg" <Gre...@ls...> wrote: > >=20 > > > Hi, > > > =20 > > > I'm using TclBlend within a Java application to add scripting > > > capabilities. > > > =20 > > > I have a C/C++ based Tcl Extension that I've developed and=20 > > want to use > > > within a Tcl_Interp. I'm able to do a 'package require' of my Tcl > > > Extension > > > =20 > > > Tcl_Interp interp; > > > interp.eval("package require Myext"); > > > interp.eval("mycmd"); > > > =20 > > > but when the extension tries to execute a Tcl C API command like > > > Tcl_AppendResult within 'mycmd' it > > > crashes with an error like: > > > =20 > > > alloc: invalid block: 0xb03be3e0: 1 0 0 > > >=20 > > > Does anyone know why this is happening? > > > =20 > > > I've done some research on this alloc command error and=20 > > what I've found > > > is that > > > it might be related to Tcl Threads. I need to make my application > > > "Thread-Safe". > > > Is this because TclBlend uses Threads? > >=20 > > Yes, Tcl Blend needs to be used with a thread safe build of=20 > > Tcl. Your extension > > also needs to be built with the same version of Tcl so that=20 > > it makes use of thread > > safe APIs. > >=20 > > > Question: Why does TclBlend need to use threads? > >=20 > > Because Tcl Blend interacts with Java and Java is multi=20 > > threaded. This means that > > thread safe APIs needs to be used in all the code running in=20 > > your process. Here is > > a link that describes how to build Tcl and Tcl Blend so that=20 > > they are thread safe. > > You should try recompiling your extension with the thread=20 > > safe version of Tcl > > you built and see if that helps. You might also check the=20 > > CFLAGS being used > > when your extension is compiled to make sure the proper flags=20 > > are being passed > > on the compiler command line. > >=20 > > http://wiki.tcl.tk/9993 > >=20 > > cheers > > Mo DeJong > >=20 > >=20 > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do you grep=20 > > through log files > > for problems? Stop! Download the new AJAX search engine that makes > > searching your log files as easy as surfing the web. =20 > > DOWNLOAD SPLUNK! > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486& > dat=3D121642 > > _______________________________________________ > > tcljava-user mailing list > > tcl...@li... > > https://lists.sourceforge.net/lists/listinfo/tcljava-user > >=20 >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep=20 > through log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. =20 > DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=103432&bid#0486&dat=121642 > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user >=20 |