Skip to content
Tcl Source Code View Ticket
Login

View Ticket

segfaults if Tcl_Panic() returns

Closed / Fixed1446864fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 11 years ago
Descriptionplain2006-03-10 00:57:02
As found by coverity on HEAD (applies to 8.4 too):

tclBasic.c line 350 & 3294
tclEvent.c line 408
tclHash.c line 539
tclInterp.c line 2214
tclListObj.c line 830, 544, 333 & 179
tclNamesp.c line 6218
tclVar.c line 4667
tclUnixInit.c line 994
mistachkinplain2006-03-10 08:02:05
Logged In: YES 
user_id=113501

Separate policy from mechanism...

1. The policy is that Tcl_Panic "must not return".
2. The mechanism is either to call the panicProc or the
built-in panic proc.

When the hook was put in for Tcl_SetPanicProc, you deferred
that policy to the application programmer, not the core itself.

You can't just un-defer it now.  Changing Tcl_Panic to call
abort() after the panicProc is a breaking change.
msoferplain2006-03-10 08:03:30
Logged In: YES 
user_id=148712

Quotes from Panic.3

Tcl_PanicProc *panicProc (in)
    Procedure to report fatal error message and abort.

To maintain consistency with the callers of Tcl_Panic,
panicProc must not return; it must call abort.

The current implementation of Tcl_Panic() permits it to
return after a suitable returning panicProc has been defined.
msoferplain2006-03-10 08:08:40
Logged In: YES 
user_id=148712

Plus many others that coverity missed, like tclVar.c line
3293. The core (and probably everybody else save joe)
assumes that Tcl_Panic() does not return, as documented and
suggested by the function's name.
hobbsplain2006-03-10 09:37:21
Logged In: YES 
user_id=72656

It is common knowledge that Tcl_SetPanicProc is the one
mechanism that can be used to handle low memory conditions.
 In fact, it was one of the original reasons for being. 
Until we have an alternate documented mechanism, we should
not change Tcl_Panic's behavior.
jan.nijtmanswiki2015-09-23 11:26:03

Fixed in trunk [4a27b0487a8d9860].

Log in (anonymous is fine) to add a comment.