Skip to content
Tcl Source Code Artifact [b23cf44e38]
Login

Artifact [b23cf44e38]

Artifact b23cf44e38577bd17d04ccb399826713be249ddec2f32aa25f39c00580cd6c83:

Ticket change [b23cf44e38] - Ticket [f2ff05fc8411be80|f2ff05fc84] <i>Usage of static systemEncoding is not thread safe (vulnerability)</i> status still Open with 3 other changes by sebres on 2021-04-15 15:33:49.
D 2021-04-15T15:33:49.913
J icomment Well,\sTSD\ssolution\swould\sbe\spossible,\sbut\sin\ssimplest\scase\sit\swould\simply\sindirectly\sthat\sthe\ssetting\sof\ssystem\sencoding\saffects\sonly\scurrent\sthread\s(and\sall\sof\sits\sinterpreters),\swhat\swould\sbe\sbackwards\sincompatible.\r\n\r\nHere\sis\sa\sdiff\sexplaining\sthat:\r\n<code><pre\sstyle="padding-left:10pt">\r\n#\s[T0]\smain\sthread\sset\ssystem\sencoding\sto\s"cp1252"\r\n...\r\n#\s[T1]\sthen\sat\ssome\spoint\sthread\s1\sdoing:\r\n%\sencoding\ssystem\sutf-8\r\nutf-8\r\n#\s[T2]\shereafter\sin\sother\sthread:\r\n%\sencoding\ssystem\r\n<b\sstyle="color:red">-utf-8</b>\r\n<b\sstyle="color:green">+cp1252</b>\r\n</pre></code>\r\n\r\nSure,\sone\scould\sadditionally\sstore\san\sepoch\sin\sTSD\sand\scompare\sit\swith\sa\scommon\sstatic\sepoch\swhich\sgets\sincremented\sby\sTcl_SetSystemEncoding,\sso\san\saccess\sby\sTcl_GetEncoding(interp,\sNULL)\scould\scheck\sit\sand\sinvalidate\scached\sin\sTSD\sencoding\sif\sepoch\schanged\sglobally.\r\n\r\nJust\swhole\sperformance\sof\sthat\s(TSD+epoch)\swill\sbe\salmost\scomparable\sto\sa\ssimple\slock\svariant\s(in\scase\sof\sNULL\sby\sencoding),\sso\ssimilat\sto:\sget\sand\sincr\sref\sin\slock,\sconvert,\sand\sdecr\sref\sin\slock\sat\send.\r\n\r\nFWIW:\sin\smy\sfork\sI\sused\ssimilar\sway,\swithout\sTSD\sand\sinterim\slock\s(with\satomic\srefCount\sincrement/decrement\sand\san\sepoch\sused\sonly\sfor\sTcl_ObjType\s"encoding"\scached\sin\stcl-object).
J login sebres
J mimetype text/x-fossil-wiki
K f2ff05fc8411be80a93913b2b065f2c85fa9bcf0
U sebres
Z cbd5ac9068781f0400f360a7f66bff61