On Fri, 14 Jul 2000, Mike Schwartz wrote:

> Hi,

Hi Mike.

> I am using Tcl 8.3.0 with tclBlend 1.3.0 (with the code for the testthread 
> command compiled in) and Java JS2E v1.3 beta.  When my software first 
> starts, I need to invoke a static Java method, and then later I need to 
> spawn a Tcl thread that invokes more Java methods (both static and instance 
> methods).  I find that the Tcl thread's Java invocation does not work, as 
> demonstrated by the following code snippet:
> 
>      1   package require java
>      2   java::call Integer parseInt 3
>      3   set th [testthread create]
>      4   testthread send $th [list set env(LD_LIBRARY_PATH) \
$env(LD_LIBRARY_PATH)]
>      5   testthread send $th [list package require java]
>      6   testthread send $th [list java::call Integer parseInt 3]
> 
> [Line numbers above are just for discussion, they're not in the actual tcl 
> script file.]
> 
> Basically, if you create a thread and then try to send it some tclblend
> commands to run, it doesn't work right.  The "package require java" at
> line 5 causes the following error output:
>      #
>      # HotSpot Virtual Machine Error, Unexpected Signal 11
>      # Please report this error at
>      # http://java.sun.com/cgi-bin/bugreport.cgi
>      #
>      # Error ID: 4F533F534F4C415249530E4350500820 01
>      #
>      # Problematic Thread: Segmentation fault

I tested out your example code with IBM JDK 1.3 and got
(what I can only assume is) the same error. Here is the stack trace.

(gdb) bt
#0  0x4011fd41 in __kill () from /lib/libc.so.6
#1  0x400d7c33 in __pthread_restart_new (th=0x400df940) at pthread.c:809
#2  0x400d51cc in pthread_cond_broadcast (cond=0x81ff860) at restart.h:21
#3  0x400af2a6 in Tcl_ConditionNotify (condPtr=0x81ff830) at 
/home/mo/project/tcl/unix/../unix/tclUnixThrd.c:715
#4  0x8058946 in ThreadEventProc (evPtr=0x81ff7f8, mask=-3) at 
/home/mo/project/tcl/unix/../generic/tclThreadTest.c:893
#5  0x4008a1e8 in Tcl_ServiceEvent (flags=-3) at 
/home/mo/project/tcl/unix/../generic/tclNotify.c:607
#6  0x4008a63b in Tcl_DoOneEvent (flags=-3) at 
/home/mo/project/tcl/unix/../generic/tclNotify.c:910
#7  0x8057d3d in Tcl_ThreadObjCmd (dummy=0x0, interp=0x81f8d80, objc=2, 
objv=0xbefffb58) at /home/mo/project/tcl/unix/../generic/tclThreadTest.c:358
#8  0x4008d07f in EvalObjv (interp=0x81f8d80, objc=2, objv=0xbefffb58, 
command=0x8202d60 "testthread wait", length=15, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:932
#9  0x4008d974 in Tcl_EvalEx (interp=0x81f8d80, script=0x8202d60 
"testthread wait", numBytes=15, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:1393
#10 0x4008dc75 in Tcl_Eval (interp=0x81f8d80, string=0x8202d60 
"testthread wait") at /home/mo/project/tcl/unix/../generic/tclParse.c:1512
#11 0x8058030 in NewThread (clientData=0xbfffe954) at 
/home/mo/project/tcl/unix/../generic/tclThreadTest.c:512
#12 0x400d5b85 in pthread_start_thread (arg=0xbefffe40) at manager.c:241
#13 0x400d654c in pthread_start_thread_event (arg=0xbefffe40) at 
manager.c:264


It is crashing at line 715 in tclUnixThrd.c, it is
the call to pthread_cond_broadcast() that seems
to be going bad.

        710     Tcl_ConditionNotify(condPtr)
        711         Tcl_Condition *condPtr;
-       712     {
-       713         pthread_cond_t *pcondPtr = *((pthread_cond_t **)condPtr);
-       714         if (pcondPtr != NULL) {
-       715             pthread_cond_broadcast(pcondPtr);
-       716         } else {
        717             /*
        718              * Noone has used the condition variable, so 
there are no waiters.
        719              */
        720         }
-       721     }



I don't know too much about the guts of pthreads, but
here is what I am getting for the pcondPtr variable.

(gdb) print *pcondPtr
$2 = {__c_lock = {__status = 0, __spinlock = 0}, __c_waiting = 0x0}


Perhaps the JVM and Tcl are using the same signals to
do inter thread communication or something. Does anyone
have any ideas what this one might be?

Things get even more strange when I run this in JDK 1.1.8
from Blackdown. Here is the stack trace I get there.

#0  0x4026cca6 in ?? ()
#1  0x40258f1d in ?? ()
#2  0x4020f03e in ?? ()
#3  0x400854e4 in Tcl_LoadObjCmd (dummy=0x0, interp=0x808e760, objc=2, 
objv=0x818e730) at /home/mo/project/tcl/unix/../generic/tclLoad.c:384
#4  0x4008d07f in EvalObjv (interp=0x808e760, objc=2, objv=0x818e730, 
command=0x400b88f4 "", length=0, flags=262144) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:932
#5  0x4008d204 in Tcl_EvalObjv (interp=0x808e760, objc=2, objv=0x818e730, 
flags=262144) at /home/mo/project/tcl/unix/../generic/tclParse.c:1019
#6  0x40038eb5 in Tcl_EvalObjEx (interp=0x808e760, objPtr=0x818e1f0, 
flags=262144) at /home/mo/project/tcl/unix/../generic/tclBasic.c:2575
#7  0x40096139 in Tcl_UplevelObjCmd (dummy=0x0, interp=0x808e760, objc=2, 
objv=0x816a564) at /home/mo/project/tcl/unix/../generic/tclProc.c:614
#8  0x40060bb6 in TclExecuteByteCode (interp=0x808e760, 
codePtr=0x818f9f8) at /home/mo/project/tcl/unix/../generic/tclExecute.c:847
#9  0x400391ba in Tcl_EvalObjEx (interp=0x808e760, objPtr=0x817f440, 
flags=0) at /home/mo/project/tcl/unix/../generic/tclBasic.c:2733
#10 0x4009687a in TclObjInterpProc (clientData=0x818dc58, 
interp=0x808e760, objc=3, objv=0x816a550) at 
/home/mo/project/tcl/unix/../generic/tclProc.c:1014
#11 0x40060bb6 in TclExecuteByteCode (interp=0x808e760, 
codePtr=0x818e8a8) at /home/mo/project/tcl/unix/../generic/tclExecute.c:847
#12 0x400391ba in Tcl_EvalObjEx (interp=0x808e760, objPtr=0x817f458, 
flags=0) at /home/mo/project/tcl/unix/../generic/tclBasic.c:2733
#13 0x4009687a in TclObjInterpProc (clientData=0x818d9f0, 
interp=0x808e760, objc=6, objv=0x816a538) at 
/home/mo/project/tcl/unix/../generic/tclProc.c:1014
#14 0x40060bb6 in TclExecuteByteCode (interp=0x808e760, 
codePtr=0x818f458) at /home/mo/project/tcl/unix/../generic/tclExecute.c:847
#15 0x400391ba in Tcl_EvalObjEx (interp=0x808e760, objPtr=0x817f560, 
flags=0) at /home/mo/project/tcl/unix/../generic/tclBasic.c:2733
#16 0x4009687a in TclObjInterpProc (clientData=0x818d408, 
interp=0x808e760, objc=6, objv=0x816a520) at 
/home/mo/project/tcl/unix/../generic/tclProc.c:1014
#17 0x40060bb6 in TclExecuteByteCode (interp=0x808e760, 
codePtr=0x818c070) at /home/mo/project/tcl/unix/../generic/tclExecute.c:847
#18 0x400391ba in Tcl_EvalObjEx (interp=0x808e760, objPtr=0x817f968, 
flags=0) at /home/mo/project/tcl/unix/../generic/tclBasic.c:2733
#19 0x4009687a in TclObjInterpProc (clientData=0x818b4a0, 
interp=0x808e760, objc=2, objv=0xbf1ff384) at 
/home/mo/project/tcl/unix/../generic/tclProc.c:1014
#20 0x4008d07f in EvalObjv (interp=0x808e760, objc=2, objv=0xbf1ff384, 
command=0x818b638 "loadtclblend /home/mo/project/build/tcljava", 
length=43, flags=0) at /home/mo/project/tcl/unix/../generic/tclParse.c:932
#21 0x4008d974 in Tcl_EvalEx (interp=0x808e760, script=0x818b638 
"loadtclblend /home/mo/project/build/tcljava", numBytes=43, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:1393
#22 0x4008dc75 in Tcl_Eval (interp=0x808e760, string=0x818b638 
"loadtclblend /home/mo/project/build/tcljava") at 
/home/mo/project/tcl/unix/../generic/tclParse.c:1512
#23 0x4003ae7d in Tcl_GlobalEval (interp=0x808e760, command=0x818b638 
"loadtclblend /home/mo/project/build/tcljava") at 
/home/mo/project/tcl/unix/../generic/tclBasic.c:4149
#24 0x400923fd in Tcl_PkgRequireEx (interp=0x808e760, name=0x8170568 
"java", version=0x0, exact=0, clientDataPtr=0x0) at 
/home/mo/project/tcl/unix/../generic/tclPkg.c:251
#25 0x400922af in Tcl_PkgRequire (interp=0x808e760, name=0x8170568 
"java", version=0x0, exact=0) at 
/home/mo/project/tcl/unix/../generic/tclPkg.c:163
#26 0x400930d5 in Tcl_PackageObjCmd (dummy=0x0, interp=0x808e760, objc=3, 
objv=0xbf1ff7d0) at /home/mo/project/tcl/unix/../generic/tclPkg.c:672
#27 0x4008d07f in EvalObjv (interp=0x808e760, objc=3, objv=0xbf1ff7d0, 
command=0x81704d8 "package require java", length=20, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:932
#28 0x4008d974 in Tcl_EvalEx (interp=0x808e760, script=0x81704d8 "package 
require java", numBytes=20, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:1393
#29 0x4008dc75 in Tcl_Eval (interp=0x808e760, string=0x81704d8 "package 
require java") at /home/mo/project/tcl/unix/../generic/tclParse.c:1512
#30 0x4003ae7d in Tcl_GlobalEval (interp=0x808e760, command=0x81704d8 
"package require java") at 
/home/mo/project/tcl/unix/../generic/tclBasic.c:4149
#31 0x80587e0 in ThreadEventProc (evPtr=0x81704c0, mask=-3) at 
/home/mo/project/tcl/unix/../generic/tclThreadTest.c:868
#32 0x4008a1e8 in Tcl_ServiceEvent (flags=-3) at 
/home/mo/project/tcl/unix/../generic/tclNotify.c:607
#33 0x4008a63b in Tcl_DoOneEvent (flags=-3) at 
/home/mo/project/tcl/unix/../generic/tclNotify.c:910
#34 0x8057d3d in Tcl_ThreadObjCmd (dummy=0x0, interp=0x808e760, objc=2, 
objv=0xbf1ffb58) at /home/mo/project/tcl/unix/../generic/tclThreadTest.c:358
#35 0x4008d07f in EvalObjv (interp=0x808e760, objc=2, objv=0xbf1ffb58, 
command=0x8174a70 "testthread wait", length=15, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:932
#36 0x4008d974 in Tcl_EvalEx (interp=0x808e760, script=0x8174a70 
"testthread wait", numBytes=15, flags=0) at 
/home/mo/project/tcl/unix/../generic/tclParse.c:1393
#37 0x4008dc75 in Tcl_Eval (interp=0x808e760, string=0x8174a70 
"testthread wait") at /home/mo/project/tcl/unix/../generic/tclParse.c:1512
#38 0x8058030 in NewThread (clientData=0xbfffe9a4) at 
/home/mo/project/tcl/unix/../generic/tclThreadTest.c:512
#39 0x400d5b85 in pthread_start_thread (arg=0xbf1ffe40) at manager.c:241
#40 0x400d654c in pthread_start_thread_event (arg=0xbf1ffe40) at 
manager.c:264



The code this part pukes on in from tclLoad.c, line 384.


-       372         if (Tcl_IsSafe(target)) {
-       373             if (pkgPtr->safeInitProc != NULL) {
-       374                 code = (*pkgPtr->safeInitProc)(target);
-       375             } else {
-       376                 Tcl_AppendResult(interp,
        377                         "can't use package in a safe 
interpreter: ",
        378                         "no ", pkgPtr->packageName, 
"_SafeInit procedure",
        379                         (char *) NULL);
-       380                 code = TCL_ERROR;
-       381                 goto done;
        382             }
-       383         } else {
-       384             code = (*pkgPtr->initProc)(target);
        385         }


It seems to want to call Tcl_PakcageInitProc. Does anyone
have any ideas on this one?

Mo DeJong
Red Hat Inc

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to