Overview
| Artifact ID: | 612a6abf634b7c8da748292575adef6de7f7b7376bf58810ebef9b433e3c15c9 |
|---|---|
| Ticket: | 31294d48efe6ead48dcd44677774b026045d5cb6
Threaded allocator cannot be disabled in Tcl 9: -DUSE_THREAD_ALLOC=0 and nmake OPTS=tclalloc ignored |
| User & Date: | jan.nijtmans on 2026-10-20 20:42:12 |
Changes
- assignee changed to: "aku"
- closer changed to: "nobody"
- comment changed to:
In Tcl 9 there is no way to build without the threaded ("zippy") allocator, other than <tt>PURIFY</tt> or <tt>TCL_MEM_DEBUG</tt>. Asking for it explicitly is silently ignored: <verbatim> CFLAGS="-O2 -DUSE_THREAD_ALLOC=0" ../unix/configure && make nm tclThreadAlloc.o | grep ' T TclpAlloc' # found: zippy is compiled in nm tclAlloc.o | grep ' T ' # empty </verbatim> Expected: <tt>tclThreadAlloc.c</tt> compiles the stub, and <tt>TclpAlloc</tt> comes from <tt>tclAlloc.c</tt> (system <tt>malloc()</tt>). Cause: <tt>generic/tclInt.h</tt> has <verbatim> #if TCL_THREADS && !defined(USE_THREAD_ALLOC) # define USE_THREAD_ALLOC 1 #endif </verbatim> and every user (<tt>tclInt.h</tt>, <tt>tclAlloc.c</tt>, <tt>tclThreadAlloc.c</tt>, <tt>tclBasic.c</tt>, <tt>tclEvent.c</tt>, <tt>tclThread.c</tt>, <tt>unix/tclUnixThrd.c</tt>, <tt>win/tclWinThrd.c</tt>) tests <tt>defined(USE_THREAD_ALLOC)</tt>, not its value. So <tt>-DUSE_THREAD_ALLOC=0</tt> means "on", and leaving it undefined also means "on". The default was added in [f2c996cdb8] (2018), when <tt>configure</tt> stopped defining <tt>USE_THREAD_ALLOC=1</tt>. The same applies to the Windows build: <tt>nmake -f makefile.vc OPTS=tclalloc</tt> sets <tt>USE_THREAD_ALLOC = 0</tt> in <tt>win/rules.vc</tt>, but <tt>/DUSE_THREAD_ALLOC</tt> is passed only when <tt>TCL_VERSION < 87</tt>, so for Tcl 9 nothing reaches the compiler and <tt>tclInt.h</tt> turns the allocator on (found by reading <tt>rules.vc</tt>, not tested on Windows). In 8.6 <tt>OPTS=tclalloc</tt> does work. In 8.6 on Unix, <tt>configure</tt> always adds <tt>-DUSE_THREAD_ALLOC=1</tt> for threaded builds, which is the old RFE [1079199fff]; the workaround there (removing it from <tt>Makefile</tt> and <tt>tclConfig.sh</tt>) does not apply to 9.x, where there is nothing to remove. Seen with 9.0.5 and main (9.1). Possible fix: in <tt>tclInt.h</tt>, <tt>#undef</tt> <tt>USE_THREAD_ALLOC</tt> when it is defined as 0, and let <tt>rules.vc</tt> pass <tt>/DUSE_THREAD_ALLOC=0</tt> for <tt>OPTS=tclalloc</tt>. - icomment:
This apparently was an oversight, it should be possible to override this. +1. Patch looks good to me. Can be merged.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"