Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1034e112f5a9243eb451a03c26e49d97ac39b6791681137b9f0f3e4863458db4
Ticket: c35e347c6fb8df66917b1ab6974b3638925b4aa2
Concurrent Tcl_Init calls race in Unix locale initialization, causing crashes on OpenBSD
User & Date: serhiy.storchaka on 2026-10-18 21:44:14
Changes

  1. icomment:
    Partly. Since [63941fee4f], <tt>Tcl_Init()</tt> no longer calls <tt>setlocale()</tt> once the initial encoding is set, so <tt>tcl-thread-init-race.tcl</tt> no longer crashes on OpenBSD (0 of 10 runs, 10 of 10 just before that merge). But <tt>Tcl_GetEncodingNameFromEnvironment()</tt> still calls <tt>setlocale()</tt> without a lock: from <nowiki>[encoding user]</nowiki>, from <tt>Tcl_GetEncodingNameForUser()</tt>, and from every <tt>Tcl_Init()</tt> as long as the initial encoding was not found. The attached <tt>c35e347c6f-encoding-user-race.tcl</tt> (8 threads doing <nowiki>[encoding user]</nowiki> in a loop) crashes the current trunk on OpenBSD in 10 of 10 runs, and does not crash with the patch in branch [/timeline?r=unix-locale-init-lock|unix-locale-init-lock]. So the patch is still needed.
    
  2. login: "serhiy.storchaka"
  3. mimetype: "text/x-fossil-wiki"