Tcl Source Code

View Ticket
Login
Ticket UUID: 976496
Title: complex Tcl/Tk apps run out of TLS indexes on Win32...
Type: Patch Version: None
Submitter: mistachkin Created on: 2004-06-21 03:14:13
Subsystem: 49. Threading Assigned To: mistachkin
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2004-06-24 15:18:54
Resolution: Accepted Closed By: mistachkin
    Closed on: 2004-06-24 08:18:54
Description:
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.
User Comments: dgp added on 2004-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.

kennykb added on 2004-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.

mistachkin added on 2004-06-23 05:07:34:

File Added - 91562: threadStorage5.zip

mistachkin added on 2004-06-23 05:07:33:
Logged In: YES 
user_id=113501

Patch updated, fixes non-threaded warnings on Win32 with 
VC++.

mistachkin added on 2004-06-23 05:06:36:

File Deleted - 91550:

dgp added on 2004-06-23 03:40:35:

File Deleted - 91548: 



File Added - 91554: 976496.patch

mistachkin added on 2004-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.

mistachkin added on 2004-06-23 02:37:20:

File Deleted - 91488:

dgp added on 2004-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.

dgp added on 2004-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?

dgp added on 2004-06-22 20:58:38:

File Deleted - 91427:

dgp added on 2004-06-22 20:58:37:
Logged In: YES 
user_id=80530

deleted.  will produce
another after some testing.

mistachkin added on 2004-06-22 17:00:13:

File Added - 91488: threadStorage4.zip

mistachkin added on 2004-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?

mistachkin added on 2004-06-22 16:01:43:

File Deleted - 91438:

mistachkin added on 2004-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?

mistachkin added on 2004-06-22 06:51:28:

File Added - 91438: threadStorage3.zip

Logged In: YES 
user_id=113501


This new patch should fix the previous problems.

mistachkin added on 2004-06-22 06:49:11:

File Deleted - 91421:

dgp added on 2004-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`

mistachkin added on 2004-06-22 04:01:47:

File Added - 91421: threadStorage2.zip

mistachkin added on 2004-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".

dkf added on 2004-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... :^)

mistachkin added on 2004-06-21 10:14:13:

File Added - 91318: threadStorage.zip

Attachments: