RE: [tcljava-user] Tcl Extension
by Greg Pierce other posts by this author
Feb 9 2006 9:09AM messages near this date
Re: [tcljava-user] Tcl Extension
|
RE: [tcljava-user] Tcl Extension
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: tcljava-user-admin@[...].net
> [mailto:tcljava-user-admin@[...].net] On Behalf
> Of Pierce, Greg
> Sent: Wednesday, February 08, 2006 2:05 PM
> To: tcljava-user@[...].net
> Subject: RE: [tcljava-user] Tcl Extension
>
> Hi Mo DeJong,
>
> I can get my simple Tcl Extension to work in TclBlend if I do the
> following:
>
>
> Interp *iPtr = (Interp *) interp;
> Tcl_IncrRefCount(iPtr->objResultPtr);
>
> Tcl_WrongNumArgs(interp, 0, argv, "?pattern?");
>
> The above Tcl_WrongNumArgs command will fail with the alloc error if I
> don't
> Increment the ref count for objResultPtr of the interpreter.
>
> Does anyone know why I would have to do this? Why is the data
> 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.
>
> 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
> Extension as
> you can get and should work in TclBlend.
>
> Greg
>
>
> > -----Original Message-----
> > From: tcljava-user-admin@[...].net
> > [mailto:tcljava-user-admin@[...].net] On Behalf
> > Of Mo DeJong
> > Sent: Monday, February 06, 2006 9:27 PM
> > To: tcljava-user@[...].net
> > Subject: Re: [tcljava-user] Tcl Extension
> >
> > On Mon, 6 Feb 2006 13:40:10 -0700
> > "Pierce, Greg" <Greg.Pierce@[...].com> wrote:
> >
> > > Hi,
> > >
> > > I'm using TclBlend within a Java application to add scripting
> > > capabilities.
> > >
> > > I have a C/C++ based Tcl Extension that I've developed and
> > want to use
> > > within a Tcl_Interp. I'm able to do a 'package require' of my Tcl
> > > Extension
> > >
> > > Tcl_Interp interp;
> > > interp.eval("package require Myext");
> > > interp.eval("mycmd");
> > >
> > > but when the extension tries to execute a Tcl C API command like
> > > Tcl_AppendResult within 'mycmd' it
> > > crashes with an error like:
> > >
> > > alloc: invalid block: 0xb03be3e0: 1 0 0
> > >
> > > Does anyone know why this is happening?
> > >
> > > I've done some research on this alloc command error and
> > 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?
> >
> > Yes, Tcl Blend needs to be used with a thread safe build of
> > Tcl. Your extension
> > also needs to be built with the same version of Tcl so that
> > it makes use of thread
> > safe APIs.
> >
> > > Question: Why does TclBlend need to use threads?
> >
> > Because Tcl Blend interacts with Java and Java is multi
> > threaded. This means that
> > thread safe APIs needs to be used in all the code running in
> > your process. Here is
> > a link that describes how to build Tcl and Tcl Blend so that
> > they are thread safe.
> > You should try recompiling your extension with the thread
> > safe version of Tcl
> > you built and see if that helps. You might also check the
> > CFLAGS being used
> > when your extension is compiled to make sure the proper flags
> > are being passed
> > on the compiler command line.
> >
> > http://wiki.tcl.tk/9993
> >
> > cheers
> > Mo DeJong
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep
> > through log files
> > for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web.
> > DOWNLOAD SPLUNK!
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> dat=121642
> > _______________________________________________
> > tcljava-user mailing list
> > tcljava-user@[...].net
> > https://lists.sourceforge.net/lists/listinfo/tcljava-user
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web.
> DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
> _______________________________________________
> tcljava-user mailing list
> tcljava-user@[...].net
> https://lists.sourceforge.net/lists/listinfo/tcljava-user
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
tcljava-user mailing list
tcljava-user@[...].net
https://lists.sourceforge.net/lists/listinfo/tcljava-user
Thread:
Greg Pierce
Mo DeJong
Greg Pierce
Greg Pierce
Greg Pierce
|