Mantis - Squeak
Viewing Issue Advanced Details
5795 Collections minor always 01-20-07 14:39 01-20-07 14:45
R4p70r  
 
normal  
new 3.9  
open  
none    
none  
0005795: TranscriptStream is not completely thread safe
TranscriptStream is expected to be thread safe and there's a semaphore critical section in #endEntry to ensure this.

But before #endEntry gets to display the stream content, the #show: method first has to put something on the TranscriptStream and that's _not_ thread safe.
A simple test. The 'b' rarely appears when you evaluate this:

Transcript clear.
[Transcript show: (String new: 1000 withAll: $a)] fork.
[Transcript show: $b] fork.

Fix 2 places the critical section in #show instead of #endEntry
 FixTranscriptStream-Threads-alexj.2.cs [^] (520 bytes) 01-20-07 14:40
 FixTranscriptStream-Threads-alexj.3.cs [^] (1,059 bytes) 01-20-07 14:45

Notes
(0009088)
R4p70r   
01-20-07 14:44   
Fix number 3 uses a monitor instead. In both #endEntry and #show:

Keeping #critical: in #endEntry may help since several methods call #endEntry directly. Note that won't work perfectly since in thoses methods send stream messages before calling #endEntry and they are not thread safe.