Check-in [f76fd0373c]

Login
FlightAware bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:typo's, improve wording.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:f76fd0373c69ea3bfd5439f956c85a79407aa0ef3a212aa8c6dc0aa6f87b6ed3
User & Date: jan.nijtmans 2018-06-26 07:36:36
Context
2018-07-04
09:42
Update 483 status. check-in: f242c154fe user: stu tags: trunk
2018-06-26
07:36
typo's, improve wording. check-in: f76fd0373c user: jan.nijtmans tags: trunk
2018-06-25
20:41
New TIP: 512 check-in: c348a9d6eb user: jan.nijtmans tags: trunk
Changes

Changes to tip/512.md.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
`Tcl_SetPanicProc()`, `Tcl_FindExecutable()` and (for Tk) `Tk_MainEx()`.
The normal exported symbols for those functions will be kept intact.

# Context

This TIP is inspired by Tcl commit ["Add custom exit procedure for
tcltests executable"](http://core.tcl.tk/tcl/info/6f650b4271a1ef2e)
(thanks to Poor Yorick!). This commit demonstrates exactly what's the problem
when using `Tcl_SetExitProc()` in a stub-enabled extension.

# Rationale

When running test-cases in Windows (using mingw-64 or msvc, but using the
win/Makefile system not the nmake system), the tcltest executable
crashes after shutdown with some tests. The reason for this is that
the additional test-code "tcltest" is compiled as stub-enabled extension
which is dynamically loaded into tclsh. So, there is no "tcltest"
executable in this environment, all there is is tclsh86.exe and
tcltest86.dll.

If a stub-enabled extension registers an Exit-handler, the following
happens at exit time. During the clean-up, Tcl unloads all extensions.
When the clean-up is done, the last step is calling the registered
Exit-handler. But ... since the exit handler function was located
inside the dll, it's address space is gone already. This results
in the mentioned crash.

The same problem exists in `Tcl_SetPanicProc()`: If a stub-enabled
extension registers a Panic proc which is located in its own
address space, the extension might be gone when the panicproc is
finally called.

`Tcl_FindExecutable()` and `Tk_MainEx()` don't register functions,
but those functions - too - are meant to be used at application
level, not at extension level. Therefore those don't belong in
the stub table either.

# Specification

The above mentioned functions are marked with _nostub_, and the
tools/genStubs.tcl tooling is adapted to recognize this special
keyword. It means that the function entry in the stub table is
marked as deprecated, but the normal function entry is leaf as-is.

When Tcl is compiled with -DTCL\_NO\_DEPRECATED, the stub entries for
the above functions will no longer be available. The stub table
entries for those function will be filled with 0 instead.

Starting with Tcl 9.0, those stub entries will be removed completely.
In stead, those functions will be defined in tcl.h, as normal
exported symbols, just like `Tcl_MainEx()` (for example).

# Implementation

Currently, the proposed implementation is available in [tip-512 branch]
(https://core.tcl.tk/tk/timeline?r=tip-512).

# Copyright

This document has been placed in the public domain.







|
|




|
|


|
|








|











|
|
|
|












|




15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
`Tcl_SetPanicProc()`, `Tcl_FindExecutable()` and (for Tk) `Tk_MainEx()`.
The normal exported symbols for those functions will be kept intact.

# Context

This TIP is inspired by Tcl commit ["Add custom exit procedure for
tcltests executable"](http://core.tcl.tk/tcl/info/6f650b4271a1ef2e)
(thanks to Poor Yorick!). This commit demonstrates exactly what's the
problem when using `Tcl_SetExitProc()` in a stub-enabled extension.

# Rationale

When running test-cases in Windows (using mingw-64 or msvc, but using the
win/Makefile system not the nmake system), the tclsh executable
crashes after shutdown in some tests. The reason for this is that
the additional test-code "tcltest" is compiled as stub-enabled extension
which is dynamically loaded into tclsh. So, there is no "tcltest"
executable in this environment, tclsh86.exe and tcltest86.dll are
sufficient.

If a stub-enabled extension registers an Exit-handler, the following
happens at exit time. During the clean-up, Tcl unloads all extensions.
When the clean-up is done, the last step is calling the registered
Exit-handler. But ... since the exit handler function was located
inside the dll, it's address space is gone already. This results
in the mentioned crash.

A similar problem exists in `Tcl_SetPanicProc()`: If a stub-enabled
extension registers a Panic proc which is located in its own
address space, the extension might be gone when the panicproc is
finally called.

`Tcl_FindExecutable()` and `Tk_MainEx()` don't register functions,
but those functions - too - are meant to be used at application
level, not at extension level. Therefore those don't belong in
the stub table either.

# Specification

The above mentioned functions are marked with _nostub_ (in tcl.decls),
and the tools/genStubs.tcl tooling is adapted to recognize this special
keyword. The effect is that the function entry in the stub table is
marked as deprecated, but the normal function entry is left as-is.

When Tcl is compiled with -DTCL\_NO\_DEPRECATED, the stub entries for
the above functions will no longer be available. The stub table
entries for those function will be filled with 0 instead.

Starting with Tcl 9.0, those stub entries will be removed completely.
In stead, those functions will be defined in tcl.h, as normal
exported symbols, just like `Tcl_MainEx()` (for example).

# Implementation

Currently, the proposed implementation is available in [tip-512 branch]
(https://core.tcl.tk/tcl/timeline?r=tip-512).

# Copyright

This document has been placed in the public domain.