Check-in [c348a9d6eb]

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

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

Overview
Comment:New TIP: 512
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:c348a9d6eb161f84a7d011764e5f4a4ebd7c8736e3b51bf58cccc930625d9775
User & Date: jan.nijtmans 2018-06-25 20:41:02
Context
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
2018-06-22
14:18
Correction from Christian Werner check-in: eadd78dd7f user: dkf tags: trunk
Changes

Changes to index.json.

cannot compute difference between binary files

Changes to index.md.

102
103
104
105
106
107
108







109
110
111
112
113
114
115
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>








<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/511.md'>511</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 511: Implement Tcl_AsyncMarkFromSignal()</td>
</tr>







>
>
>
>
>
>
>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>

<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/512.md'>512</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 512: No stub for Tcl_SetExitProc()</td>
</tr>
<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/511.md'>511</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 511: Implement Tcl_AsyncMarkFromSignal()</td>
</tr>

Added tip/512.md.





















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
# TIP 512: No stub for Tcl_SetExitProc()
	Author:         Jan Nijtmans <jan.nijtmans@gmail.com>
	State:          Draft
	Type:           Project
	Vote:           
	Created:        25-June-2018
	Post-History:   
	Keywords:       Tcl
	Tcl-Version:	8.7
-----

# Abstract

This TIP proposes to remove the stub entries for `Tcl_SetExitProc()`,
`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.