[tkined] Example script to crash multithread TCL/TNM/TCLHTTPD

From: Matthew Krenzer (krenzer@wayport.net)
Date: Fri Jun 23 2000 - 01:55:41 MET DST


I'm sending this to both the Scotty and Tclhttpd mailing lists since it
kind of applies to both. I'm creating several threads that use snmp to
generate information for web pages. However, if ever two threads
execute snmp commands at the same time I get a segfault.

Using gdb I have found the code to crash in a few different places:
TnmSnmpTimeoutProc, AsyncWalkProc, and TclGetIndexedScalar. (I can get
you a stack trace if you really want it - and you'll notice that one of
those commands is in TCL proper - not in an extention). I have also
rewritten the code to not use 'snmp# wait' and use vwait instead.
Things still crashed, however.

I have attached small script that faults every time on my computer. it
requires Tnm 3.0.0 and Thread 2.0. It simply creates two threads that
make async walk requests and wait for the result. I have run it under
tclsh8.3.1 and tclsh8.4

The Aironet and M683 ethernet ports belong to the second device and
should have come through thread 3076, but apparently 2051 handled them.
Thread 3076 never wakes up from its 'wait' command.

It appears that there are issues with all the mib stuff as well - quite
often I get errors parsing mib files - again only when multithreading.
(my guess is that is has to do with the caching in ~/.tnm3.0.0 - since
all the threads would use that same cache). When it gets bad I have to
remove the cache directory just to get any mibs parsed correctly.

At this point I am assuming Tnm is not thread safe. Maybe there are
issuse regarding how the Thread package creates threads that could cause
these problems (i.e. in what ways are TCL level threads different from C
level threads?). Also, a few of the segfaults where located in TCL
proper - so is it really thread safe? or is it the way it interfaces
with Tnm that caused the fault? Anyway . . .

Any help would be great. I hope I'm just doing something stupid and
that there is an easy solution. If not, and things arn't thread safe
then let me know. Depending on how much time it would take to make it
safe I might be able to convince my boss to let me contribute to the
cause.

Thank you, and sorry for being long winded.
Matthew Krenzer



yakko:~/tcltest> tclsh
% source test.tcl
% start
Starting thread 2051
2051: walking using snmp0
2051: Waiting . . .
  2051: {10MB Ethernet Port 1}
  2051: {10MB Ethernet Port 2}
  2051: {10MB Ethernet Port 3}
  2051: {10MB Ethernet Port 4}
  2051: {10MB Ethernet Port 5}
  2051: {10MB Ethernet Port 6}
  2051: {10MB Ethernet Port 7}
  2051: {10MB Ethernet Port 8}
  2051: {10MB Ethernet Port 9}
  2051: {10MB Ethernet Port 10}
  2051: {10MB Ethernet Port 11}
  2051: {10MB Ethernet Port 12}
  2051: {10MB Ethernet Port 13}
  2051: {10MB Ethernet Port 14}
  2051: {10MB Ethernet Port 15}
  2051: {10MB Ethernet Port 16}
  2051: {10MB Ethernet Port 17}
  2051: {10MB Ethernet Port 18}
  2051: {10MB Ethernet Port 19}
  2051: {10MB Ethernet Port 20}
  2051: {10MB Ethernet Port 21}
  2051: {10MB Ethernet Port 22}
  2051: {10MB Ethernet Port 23}
  2051: {10MB Ethernet Port 24}
  2051: {System Management Port}
  2051: {100MB Ethernet Port 1}
  2051: {100MB Ethernet Port 2}
2051: Done waiting
2051: walking using snmp0
2051: Waiting . . .
  2051: {10MB Ethernet Port 1}
  2051: {10MB Ethernet Port 2}
  2051: {10MB Ethernet Port 3}
  2051: {10MB Ethernet Port 4}
  2051: {10MB Ethernet Port 5}
  2051: {10MB Ethernet Port 6}
  2051: {10MB Ethernet Port 7}
  2051: {10MB Ethernet Port 8}
  2051: {10MB Ethernet Port 9}
  2051: {10MB Ethernet Port 10}
  2051: {10MB Ethernet Port 11}
  2051: {10MB Ethernet Port 12}
  2051: {10MB Ethernet Port 13}
Starting thread 3076 //starting new thread here
3076: walking using snmp1
3076: Waiting . . .
  2051: {10MB Ethernet Port 14}
  2051: {Aironet DS-SS Radio} // this should have been sent to 3076
  2051: {M683xx Ethernet} // same here
  2051: {10MB Ethernet Port 15}
  2051: {10MB Ethernet Port 16}
  2051: {10MB Ethernet Port 17}
  2051: {10MB Ethernet Port 18}
  2051: {10MB Ethernet Port 19}
  2051: {10MB Ethernet Port 20}
  2051: {10MB Ethernet Port 21}
  2051: {10MB Ethernet Port 22}
  2051: {10MB Ethernet Port 23}
  2051: {10MB Ethernet Port 24}
  2051: {System Management Port}
  2051: {100MB Ethernet Port 1}
  2051: {100MB Ethernet Port 2}
2051: Done waiting
2051: walking using snmp0
2051: Waiting . . .
  2051: {10MB Ethernet Port 1}
  2051: {10MB Ethernet Port 2}
  2051: {10MB Ethernet Port 3}
  2051: {10MB Ethernet Port 4}
  2051: {10MB Ethernet Port 5}
  2051: {10MB Ethernet Port 6}
  2051: {10MB Ethernet Port 7}
  2051: {10MB Ethernet Port 8}
  2051: {10MB Ethernet Port 9}
  2051: {10MB Ethernet Port 10}
  2051: {10MB Ethernet Port 11}
  2051: {10MB Ethernet Port 12}
  2051: {10MB Ethernet Port 13}
  2051: {10MB Ethernet Port 14}
  2051: {10MB Ethernet Port 15}
  2051: {10MB Ethernet Port 16}
  2051: {10MB Ethernet Port 17}
  2051: {10MB Ethernet Port 18}
  2051: {10MB Ethernet Port 19}
  2051: {10MB Ethernet Port 20}
  2051: {10MB Ethernet Port 21}
  2051: {10MB Ethernet Port 22}
  2051: {10MB Ethernet Port 23}
  2051: {10MB Ethernet Port 24}
  2051: {System Management Port}
  2051: {100MB Ethernet Port 1}
  2051: {100MB Ethernet Port 2}
2051: Done waiting
2051: walking using snmp0
2051: Waiting . . .
  2051: {10MB Ethernet Port 1}
  2051: {10MB Ethernet Port 2}
  2051: {10MB Ethernet Port 3}
  2051: {10MB Ethernet Port 4}
  2051: {10MB Ethernet Port 5}
  2051: {10MB Ethernet Port 6}
  2051: {10MB Ethernet Port 7}
  2051: {10MB Ethernet Port 8}
  2051: {10MB Ethernet Port 9}
  2051: {10MB Ethernet Port 10}
  2051: {10MB Ethernet Port 11}
  2051: {10MB Ethernet Port 12}
  2051: {10MB Ethernet Port 13}
  2051: {10MB Ethernet Port 14}
  2051: {10MB Ethernet Port 15}
  2051: {10MB Ethernet Port 16}
  2051: {10MB Ethernet Port 17}
  2051: {10MB Ethernet Port 18}
  2051: {10MB Ethernet Port 19}
  2051: {10MB Ethernet Port 20}
  2051: {10MB Ethernet Port 21}
  2051: {10MB Ethernet Port 22}
  2051: {10MB Ethernet Port 23}
  2051: {10MB Ethernet Port 24}
  2051: {System Management Port}
  2051: {100MB Ethernet Port 1}
  2051: {100MB Ethernet Port 2}
2051: Done waiting
2051: walking using snmp0
2051: Waiting . . .
  2051: {10MB Ethernet Port 1}
  2051: {10MB Ethernet Port 2}
  2051: {10MB Ethernet Port 3}
Segmentation fault
yakko:~/tcltest>

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 15:27:47 MET