- labels: --> tcludp
- milestone: --> v1.x
- assigned_to: nobody --> patthoyts
Problems:
[1] Tcl udp package does not receive any data.
[2] Tcl udp package seems to de-stabilize things, as the
following happens.
(a) keep getting crash (read some junk memory),
(b) panic "Tcl_SetIntObj called with shared object"
(c) panic when stack size check fails(??)
Some analysis:
Problem [1] was becuase SocketThread was getting
blocked on the following line,
WaitForSingleObject(statePtr->pkgState->waitForSockRe
ad, INFINITE);
Socket thread was waiting for the client thread to read
the socket, while the client thread just closed the
socket. Hence SocketThread never received any
SetEvent it was expecting.
Doubts:
It seems to me that event object 'sockListLock' was
being used as a lock on global list sockList. I thought
Tcl_MutexLock & Tcl_MutexUnlock can be used over
here? Also, doesn't SetEvent release all threads that are
waiting for the event to be signalled.
[From MSDN:
"Any number of waiting threads, or threads that
subsequently begin wait operations for the specified
event object by calling one of the wait functions, can be
released while the object's state is signaled."
]
In multi-threaded scripts, multiple threads would be
waiting for the signal on the event object. When it is
signalled, all of them would be released, in which case
more than one thread would potentially enter the critical
section (section accessing the global list).
When I replaced this WaitForSingleObject with Tcl Mutex,
Problem [1] was cured. But when I ran (my) tests for
more than 10 times TCL still crashed. No Idea why :(.
I have run my tests disabling UDP for more than 200 runs
without any issue. So the problem does seem to be
somewhere hidden within udp module. Also, my tests run
fine on unix/solaris with udp module (crashed on linux only
twise in last 1.5 years).