Artifact
4ae5c15ffc9da3a10e5e873441efd01593c1924a056c5db09b5f813b9c1c5e18:
Attachment "c35e347c6f-encoding-user-race.tcl" to
ticket [c35e347c6f]
added by
serhiy.storchaka
2026-10-18 21:43:18.
0000: 23 20 53 65 76 65 72 61 6c 20 74 68 72 65 61 64 # Several thread
0010: 73 20 63 61 6c 6c 69 6e 67 20 5b 65 6e 63 6f 64 s calling [encod
0020: 69 6e 67 20 75 73 65 72 5d 20 61 74 20 74 68 65 ing user] at the
0030: 20 73 61 6d 65 20 74 69 6d 65 2e 0a 23 20 43 72 same time..# Cr
0040: 61 73 68 65 73 20 6f 6e 20 4f 70 65 6e 42 53 44 ashes on OpenBSD
0050: 20 28 64 6f 75 62 6c 65 20 66 72 65 65 20 69 6e (double free in
0060: 20 73 65 74 6c 6f 63 61 6c 65 28 29 29 2e 0a 70 setlocale())..p
0070: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 54 ackage require T
0080: 68 72 65 61 64 0a 73 65 74 20 74 68 72 65 61 64 hread.set thread
0090: 73 20 7b 7d 0a 66 6f 72 20 7b 73 65 74 20 69 20 s {}.for {set i
00a0: 30 7d 20 7b 24 69 20 3c 20 38 7d 20 7b 69 6e 63 0} {$i < 8} {inc
00b0: 72 20 69 7d 20 7b 0a 20 20 20 20 6c 61 70 70 65 r i} {. lappe
00c0: 6e 64 20 74 68 72 65 61 64 73 20 5b 74 68 72 65 nd threads [thre
00d0: 61 64 3a 3a 63 72 65 61 74 65 20 2d 6a 6f 69 6e ad::create -join
00e0: 61 62 6c 65 20 7b 0a 09 66 6f 72 20 7b 73 65 74 able {..for {set
00f0: 20 6a 20 30 7d 20 7b 24 6a 20 3c 20 32 30 30 30 j 0} {$j < 2000
0100: 30 7d 20 7b 69 6e 63 72 20 6a 7d 20 7b 0a 09 20 0} {incr j} {..
0110: 20 20 20 65 6e 63 6f 64 69 6e 67 20 75 73 65 72 encoding user
0120: 0a 09 7d 0a 20 20 20 20 7d 5d 0a 7d 0a 66 6f 72 ..}. }].}.for
0130: 65 61 63 68 20 74 20 24 74 68 72 65 61 64 73 20 each t $threads
0140: 7b 0a 20 20 20 20 74 68 72 65 61 64 3a 3a 6a 6f {. thread::jo
0150: 69 6e 20 24 74 0a 7d 0a 70 75 74 73 20 6f 6b 0a in $t.}.puts ok.