Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-03-11
00:53 • Closed ticket [1901113fff]: Crash in tcl::Bgerror plus 7 other changes artifact: d6cf6c5ca8 user: dgp
00:49 • Add attachment 1901113.patch to ticket [1901113fff] artifact: 164e9e03a4 user: dgp
00:49 • Ticket [1901113fff] Crash in tcl::Bgerror status still Open with 4 other cha... artifact: b430f29f3c user: dgp
2008-02-26
04:55 • Ticket [1901113fff]: 5 changes artifact: 9e85a87d44 user: dgp
2008-02-25
09:51 • Add attachment bgerror.patch to ticket [1901113fff] artifact: e8c8018c48 user: tallniel
09:51 • Ticket [1901113fff] Crash in tcl::Bgerror status still Open with 5 other cha... artifact: 335a32f027 user: tallniel
02:26 • New ticket [1901113fff]. artifact: f4d9e888fb user: tallniel

Crash in tcl::Bgerror

Closed / Fixed1901113fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-02-25 02:26:43
The current ::tcl::Bgerror command crashes (Bus error/coredump) on Mac OS X 10.4.11 when called with empty arguments:

% info pa
8.5.2b1
% parray tcl_platform
tcl_platform(byteOrder)   = littleEndian
tcl_platform(machine)     = i386
tcl_platform(os)          = Darwin
tcl_platform(osVersion)   = 8.11.1
tcl_platform(platform)    = unix
tcl_platform(pointerSize) = 4
tcl_platform(threaded)    = 1
tcl_platform(user)        = nem
tcl_platform(wordSize)    = 4
% interp bgerror {}
::tcl::Bgerror
% tcl::Bgerror {} {}
Bus error
tallnielplain2008-02-25 09:51:24
File Added - 267826: bgerror.patch

Logged In: YES 
user_id=102050
Originator: YES

Looks like TclDefaultBgErrorHandlerObjCmd (in generic/tclEvent.c) doesn't check for error conditions when retrieving options from the dictionary. Notably, if the dictionary passed in doesn't contain either of the expected keys {-level, -code} then the code will crash as it attempts to access the NULL pointer returned from Tcl_DictObjGet. (The code is safe for -errorcode and -errorinfo).

I attach a patch to fix this bug, by assuming -level 0 and -code TCL_ERROR (which seem like reasonable defaults). Obviously, this command is unlikely to be called directly like this anyway, but it's a simple fix to avoid a crash condition.

Also assigning to dgp as ChangeLog has your name against last entry for this command.

Cheers,
Neil
File Added: bgerror.patch
dgpplain2008-02-26 04:55:57
Logged In: YES 
user_id=80530
Originator: NO


thanks for catching this.
crashing is bad; this needs
fixing.

I think the right fix, though,
is to raise an error back to
the caller if required entries
of the return options dict are
not set.
dgpplain2008-03-11 00:49:54
File Added - 269843: 1901113.patch

Logged In: YES 
user_id=80530
Originator: NO


Attached path implementing that
alternative fix; includes tests.
File Added: 1901113.patch
dgpplain2008-03-11 00:53:05
Logged In: YES 
user_id=80530
Originator: NO

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

Attachments: