Re: [tcljava-user] Tcl Extension
Brought to you by:
mdejong
From: Mo D. <md...@un...> - 2006-02-07 02:21:46
|
On Mon, 6 Feb 2006 13:40:10 -0700 "Pierce, Greg" <Gre...@ls...> 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 |