Skip to content
Tcl Source Code Artifact [086f1258bb]
Login

Artifact [086f1258bb]

Artifact 086f1258bb7898a5301bb7ee97ddc613b0a6920da4b4274d768c377417658d65:

Ticket change [086f1258bb] - Ticket [c35e347c6fb8df66|c35e347c6f] <i>Concurrent Tcl_Init calls race in Unix locale initialization, causing crashes on OpenBSD</i> status still Open with 3 other changes by gustafn3 on 2026-10-20 08:38:07.
D 2026-10-20T08:38:07.574
J icomment Ashok.\syes,\sprocess-wide\ssetup\swould\sbe\spreferable.\sFrom\sthe\sembedding\sapplication's\sperspective,\sthere\sis\sno\sneed\sto\sreset\sthe\sprocess\slocale\swhenever\sanother\sinterpreter\sis\sinitialized.\s\r\n\r\nThe\sexpected\sperformance\sdifferences\sdepend\son\sthe\sinitialization\sscope:\r\n\r\n-\sPer-interpreter\ssetup\srepeats\slocale\sdetection\sfor\severy\sinterpreter.\r\n-\sPer-thread\ssetup\sreduces\sthat\swork\swhen\sa\sthread\screates\smultiple\sinterpreters,\sbut\sstill\srepeats\sprocess-global\slocale\soperations\sfor\seach\sthread.\r\n-\sPer-process\ssetup\savoids\sboth\sforms\sof\srepetition.\r\n\r\nOn\sOpenBSD,\sthe\scurrent\sunsynchronized\scalls\scan\scrash,\sso\ssynchronization\sis\srequired\sif\sthose\scalls\sremain.\sA\sper-interpreter\slock\swould\sserialize\sthe\slocale-detection\ssection;\sa\sper-thread\sapproach\swould\sreduce\scontention\sonly\swhere\smultiple\sinterpreters\sshare\seach\sthread.\sNote,\sthat\sthe\ssubmitted\scrash-producer\screates\sone\sinterpreter\sper\sfresh\schild\sthread,\sso\sper-thread\sinitialization\salone\swould\snot\sreduce\sits\slocale-call\scount.\r\n\r\nOn\sglibc-based\sLinux\sand\smacOS,\sthe\slibc\simplementations\salready\slock\slocale\supdates\sinternally.\sRepeating\sthose\scalls\stherefore\salready\sincurs\ssynchronization,\seven\swithout\san\sadditional\sTcl\slock.\sAvoiding\sredundant\scalls\scould\sbenefit\sprobably\sthose\splatforms\sas\swell.\sAlso,\sNaviServer\swill\sbenefit\sfrom\sthis.\r\n\r\nThe\sapparent\sreason\sfor\srepeated\scalls\sis\sthe\sstartup\ssequencing\sdescribed\sabove\sTclpSetInitialEncodings():\san\searly\sattempt\smay\slack\sthe\sinformation\sneeded\sto\sload\sthe\sappropriate\sTcl\sencoding.\sThat\sseems\sto\sjustify\sretrying\sencoding\sresolution,\srather\sthan\srepeating\slibc\slocale\ssetup.\r\n\r\nCould\sthose\ssteps\sbe\sseparated—capturing\sthe\slocale/codeset\sduring\sthe\sexisting\sprotected\sinitialization\sin\sTcl_InitSubsystems(),\sthen\sresolving\sthe\scorresponding\sTcl\sencoding\slater\sif\snecessary?\r\n\r\nMy\spatch\swas\sintended\sas\sa\sminimal\scorrectness\sfix\sfor\sthe\sdemonstrated\srace\sunder\sOpenBSD;\sI\swould\swelcome\san\sinitialization\schange\sthat\sremoves\sthe\srepeated\swork.\sThe\spublic\sTcl_GetEncodingNameFromEnvironment()\sand\sTcl_GetEncodingNameForUser()\sentry\spoints\swould\sstill\sneed\stheir\sbehavior\sand\sconcurrent\suse\sconsidered\sseparately.\r\n\r\nThanks\sfor\slooking\sinto\sthis!
J login gustafn3
J mimetype text/x-markdown
K c35e347c6fb8df66917b1ab6974b3638925b4aa2
U gustafn3
Z a5979a94058fa4f351becbda0001b182