Skip to content
Tcl Source Code View Ticket
Login

View Ticket

complex Tcl/Tk apps run out of TLS indexes on Win32...

Closed / Accepted976496ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-06-21 03:14:13
Runaway usage of TLS indexes causes some operating 
systems to fail to load complex Tcl/Tk applications when 
threads are enabled.

The attached patch "fixes" the problem and successfully 
completes "make test" without any new test failures.

However, since the attached patch is non-trivial, I 
would like as many people as possible to review it before 
it is committed to HEAD.

The "tclThreadStorage.c" file should be placed in 
the "generic" directory.

I would also like some help changing the various make 
related files to include a new compile time 
option "USE_THREAD_STORAGE" which would enable the 
new generic "Thread Storage" subsystem instead of 
using pthreads on Unix and TLS on Win32.

Thanks.
mistachkinplain2004-06-21 10:14:13
File Added - 91318: threadStorage.zip
dkf Ticket [976496ffff]: 2 changes [History diff]2004-06-21 15:57:58
dkf Ticket [976496ffff]: 1 change [History diff]2004-06-21 15:58:48
dkfplain2004-06-21 20:08:04
Logged In: YES 
user_id=79902

OK, here are some issues I've spotted.

 * Don't forget to alter the other Makefiles too. :^)

 * Perhaps the right thing to do would be to #def the
TclpThreadData* functions as TclThreadStorage* functions?

 * You don't need STORAGE_LOCK and STORAGE_UNLOCK, and it is
better to use function calls for that instead of macros.

 * TclThreadStorageLockInit unfinished?

 * panic() should be Tcl_Panic()

Alas, I only have limited expertise at evaluating the
semantic content of this alteration.  Assigning to someone
who might know more than me... :^)
mistachkinplain2004-06-22 04:01:46
Logged In: YES 
user_id=113501

Patch updated.

* Modified the unix "Makefile.in" and "tcl.m4".

* Modified "tclThread.c" to call the new thread storage 
functions if USE_THREAD_STORAGE is defined.

* Removed STORAGE_LOCK and STORAGE_UNLOCK defines 
from "tclThreadStorage.c".

* TclThreadStorageLockInit is fine.

* Changed "panic" calls to "Tcl_Panic".
mistachkinplain2004-06-22 04:01:47
File Added - 91421: threadStorage2.zip
dgpplain2004-06-22 04:49:09
File Added - 91427: 976496.patch

Logged In: YES 
user_id=80530

Here are the same changes
packaged as a single patch
file.

Patch itself doesn't quite
work for me.  Without --enable-threads,
there's a link error; with --enable-threads,
tcltest hangs on startup during `make test`
mistachkinplain2004-06-22 06:49:11
File Deleted - 91421:
mistachkinplain2004-06-22 06:51:28
File Added - 91438: threadStorage3.zip

Logged In: YES 
user_id=113501


This new patch should fix the previous problems.
mistachkinplain2004-06-22 06:54:12
Logged In: YES 
user_id=113501


Oh, can somebody please update the Mac OS X files that 
need to be changed to add the "tclThreadStorage.c" file, like 
the ".project" file, I believe?
mistachkinplain2004-06-22 16:01:43
File Deleted - 91438:
mistachkinplain2004-06-22 17:00:10
Logged In: YES 
user_id=113501

Patch updated with various tweaks and performance 
enhancements.

Tested successfully on Windows NT 4 and FreeBSD 4.10-
STABLE.

Needs testing on Windows 98, Windows 2000, Solaris, Linux, 
OpenBSD, Mac OS X (also see previous note about Mac OS X 
below), some 64-bit platforms, and whatever other random 
platforms are out there.

DGP: Could you delete your patch below and recreate it if you 
would?
mistachkinplain2004-06-22 17:00:13
File Added - 91488: threadStorage4.zip
dgpplain2004-06-22 20:58:37
Logged In: YES 
user_id=80530

deleted.  will produce
another after some testing.
dgpplain2004-06-22 20:58:38
File Deleted - 91427:
dgpplain2004-06-22 21:29:26
File Added - 91517: 976496.patch

Logged In: YES 
user_id=80530


Here's the patch as a
single unidiff patch file.

With this patch I see
processes hang at
the end of their run.  Perhaps
some Mutex error during
finalization?
dgpplain2004-06-23 02:36:34
File Deleted - 91517: 



File Added - 91548: 976496.patch

Logged In: YES 
user_id=80530

Updated patch file 976496.patch
corrects the hang.
mistachkinplain2004-06-23 02:37:20
File Deleted - 91488:
mistachkinplain2004-06-23 03:12:27
File Added - 91550: threadStorage5.zip

Logged In: YES 
user_id=113501


New patch, fixes dgp's hang and cosmetic fixes.
dgpplain2004-06-23 03:40:35
File Deleted - 91548: 



File Added - 91554: 976496.patch
mistachkinplain2004-06-23 05:06:36
File Deleted - 91550:
mistachkinplain2004-06-23 05:07:33
Logged In: YES 
user_id=113501

Patch updated, fixes non-threaded warnings on Win32 with 
VC++.
mistachkinplain2004-06-23 05:07:34
File Added - 91562: threadStorage5.zip
kennykbplain2004-06-24 00:13:05
Logged In: YES 
user_id=99768

Tested the version of threadStorage5.zip uploaded on
2004-06-22 18:07, using configure/make on Windows in
all combinations of:

{mingw, vc++}

{enable-threads and without}

{--enable-symbols and --enable-symbols=mem}

No new compilation errors/warnings nor test failures.
dgpplain2004-06-24 03:35:43
File Deleted - 91554: 



File Added - 91692: 976496.patch

Logged In: YES 
user_id=80530

976496.patch updated to 
match the new threadStorage5.zip

Applies, compiles, and tests with
no new failures, both with and
without --enable-threads on both
Solaris and Linux/Alpha (64-bit).

I'd say it's ready to commit.
mistachkin Closed ticket [976496ffff]. [History diff]2004-06-24 15:18:54
Log in (anonymous is fine) to add a comment.

Attachments: