Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-06-23
07:28 • Closed ticket [746378ffff]: experimental unix stack check patch... plus 8 ot... artifact: ad19547bac user: dkf
07:28 • Add attachment unixStackCheck.v6.diff to ticket [746378ffffffffff|74637... artifact: 508b486ad9 user: dkf
2004-06-22
21:52 • Ticket [746378ffff] experimental unix stack check patch... status still Open... artifact: f68293769b user: dkf
21:52 • Ticket [746378ffff]: 5 changes artifact: 71c6f76f4e user: dkf
2003-11-13
05:55 • Ticket [746378ffff]: 4 changes artifact: fb469e64e0 user: msofer
04:59 • Ticket [746378ffff]: 4 changes artifact: f214bdf7cf user: mistachkin
2003-11-12
22:58 • Ticket [746378ffff]: 1 change artifact: 96b1fee1ae user: dkf
08:28 • Ticket [746378ffff]: 4 changes artifact: e56e9792b8 user: msofer
2003-10-13
06:35 • Ticket [746378ffff]: 4 changes artifact: cdf51f4d21 user: hobbs
2003-09-25
21:31 • Ticket [746378ffff]: 1 change artifact: cbb5c099cb user: mistachkin
2003-06-03
03:44 • Ticket [746378ffff]: 4 changes artifact: 5e56650afa user: mistachkin
03:44 • Add attachment stack.tcl to ticket [746378ffff] artifact: 50f6ba8397 user: mistachkin
03:34 • Ticket [746378ffff] experimental unix stack check patch... status still Open... artifact: ffbceec5a2 user: mistachkin
03:34 • Add attachment unixStackCheckV4.zip to ticket [746378ffffffffff|746378f... artifact: b6898c086f user: mistachkin
2003-06-01
11:24 • Ticket [746378ffff] experimental unix stack check patch... status still Open... artifact: d7c3b22455 user: mistachkin
11:24 • Add attachment unixStackCheckV3.zip to ticket [746378ffffffffff|746378f... artifact: c7046b5600 user: mistachkin
2003-05-31
08:40 • Ticket [746378ffff] experimental unix stack check patch... status still Open... artifact: a77701d198 user: mistachkin
08:40 • Add attachment unixStackCheckV2.zip to ticket [746378ffffffffff|746378f... artifact: db94b579b3 user: mistachkin
06:34 • Ticket [746378ffff] experimental unix stack check patch... status still Open... artifact: 427d626e05 user: mistachkin
05:53 • Ticket [746378ffff]: 4 changes artifact: c34718e639 user: mistachkin
05:35 • Ticket [746378ffff]: 4 changes artifact: ed8087693b user: mistachkin
05:35 • Add attachment unixStackCheck.zip to ticket [746378ffffffffff|746378fff... artifact: 89c8111405 user: mistachkin
2003-05-30
22:35 • New ticket [746378ffff] experimental unix stack check patch.... artifact: 67e9a05c49 user: mistachkin

experimental unix stack check patch...

Closed / Accepted746378ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 22 years ago
Descriptionplain2003-05-30 22:35:08
This patch has been tested on Linux, FreeBSD, and 
Solaris.

This is a VERY experimental patch.  

Please test this on your Unix platform of choice.
mistachkinplain2003-05-31 05:35:08
File Added - 51776: unixStackCheck.zip
mistachkinplain2003-05-31 05:53:12
Logged In: YES 
user_id=113501

FreeBSD 4.8-STABLE: OK.
SuSE 8.0 Linux: OK.
Solaris 8: OK.
RedHat 9.0 (?) Linux: OK.

This patch will work when compiling with threads 
enabled, however, it is not thread safe [yet].
mistachkinplain2003-05-31 06:34:05
Logged In: YES 
user_id=113501

OpenBSD 3.2: OK.
RedHat 7.3 (it wasn't 9.0): OK.
mistachkinplain2003-05-31 08:40:56
File Added - 51787: unixStackCheckV2.zip

Logged In: YES 
user_id=113501

New thread-safe version of the previous patch, various 
other clean up done.

Please test.
mistachkinplain2003-06-01 11:24:49
File Added - 51837: unixStackCheckV3.zip

Logged In: YES 
user_id=113501

Been working on this patch to fine tune it a bit more.

The defines still need to be made more portable by 
using configure.

In my opinion, here is how it should work:

On FreeBSD with threads enabled, the pthread library 
function pthread_attr_get_np function should be used 
to check the maximum stack size for each thread.  The 
reason for this is that getrlimit for RLIMIT_STACK is 
horribly broken when pthreads are used.

On FreeBSD with threads disabled, the getrlimit function 
should be used to check the maximum stack size.

So far, on all other tested operating systems (Linux, 
Solaris, OpenBSD) it looks like the getrlimit function 
should be used, regardless of whether or not threads are 
enabled.

On Linux, there is a function that is could be a good 
candidate for checking the maximum stack size, 
pthread_getattr_np.  However, it does not seem to 
report the correct stack size (at least on the version of 
Linux I tested on), making it worse than useless.

Please note that this patch is thread safe whether or not 
it uses pthreads to get the stack size.

I am unsure about NetBSD and other platforms not 
mentioned here.

It would also be nice if there was a way to explicitly 
specify the stack checking behavior from configure, 
such as --disable-stack-check (old way) and --enable-
stack-check (new way), etc.
mistachkinplain2003-06-03 03:34:27
File Added - 51966: unixStackCheckV4.zip

Logged In: YES 
user_id=113501

This has now been tested with 8.4.x.
Added casting corrections provided by jenglish.
mistachkinplain2003-06-03 03:44:52
File Added - 51967: stack.tcl

Logged In: YES 
user_id=113501

Attached a simple test script.
mistachkin Ticket [746378ffff]: 1 change [History diff]2003-09-25 21:31:14
hobbsplain2003-10-13 06:35:11
Logged In: YES 
user_id=72656

This can be added to the HEAD after the following changes:
It needs to not compile in by default - it currently does.
The super debug printfs should be handled like the TRACE 
functions in generic/tclExecute.c - with a macro at the top 
that defaults to nothing.  That will clean up the code a lot.
msoferplain2003-11-12 08:28:13
Logged In: YES 
user_id=148712

Joe: please confirm or correct my remark in patch 450795 -
namely, that this patch completely supercedes that one
dkf Ticket [746378ffff]: 1 change [History diff]2003-11-12 22:58:57
mistachkinplain2003-11-13 04:59:43
Logged In: YES 
user_id=113501

This patch doesn't modify the configure script or any of the 
test cases. After reviewing your patch, I would say we should 
probably combine the approach taken by my patch with the 
modularity of your patch (such as the 
TclpInitCheckStackSpace function and compile-time detection 
of whether the stack grows up or down, or do we prefer the 
runtime detection?).
msoferplain2003-11-13 05:55:42
Logged In: YES 
user_id=148712

Haven't looked at this in a while. I recall thinking that,
as this function is called very often, it might be better to
check the stack-growth direction at compile time to avoid
branching at run time - premature optimisation?
dkfplain2004-06-22 21:52:42
Logged In: YES 
user_id=79902

Try this version which:
 a) Applies to the current HEAD :^)
 b) Refactors the code to reduce the amount of #ifdef
hackery and conditional code; it is easier for one person to
maintain both branches of the code now...

(Appears to work non-threaded on Linux...)
dkfplain2004-06-22 21:52:44
File Added - 91518: unixStackCheck.v5.diff
dkfplain2004-06-23 07:28:15
File Deleted - 91518: 



File Added - 91568: unixStackCheck.v6.diff

Logged In: YES 
user_id=79902

Here's a version that I applied to the HEAD and which
appears clean and effective under Linux. Further development
now belongs to the bug tracker!
Log in (anonymous is fine) to add a comment.

Attachments: