Tcl Source Code

View Ticket
Login
2023-08-11
20:47 Closed ticket [d1554fca55]: Crash with ::tls::socket plus 7 other changes artifact: 922e53e466 user: kevin_walzer
20:46 Ticket [d1554fca55]: 3 changes artifact: a319e1e6f0 user: kevin_walzer
11:16 Ticket [d1554fca55]: 3 changes artifact: 6309030dea user: kevin_walzer
07:01 Ticket [d1554fca55]: 3 changes artifact: 6e16edb16d user: chrstphrchvz
01:56 Ticket [d1554fca55]: 3 changes artifact: 6dd4fa3178 user: kevin_walzer
2023-08-07
15:35 Ticket [d1554fca55]: 3 changes artifact: 07005aa384 user: kevin_walzer
15:34 Ticket [d1554fca55]: 3 changes artifact: 15f939f4b6 user: kevin_walzer
15:32 New ticket [d1554fca55]. artifact: 4fec757363 user: kevin_walzer

Ticket UUID: d1554fca55e91bacf9a719eb87cbd6e8a3f0df78
Title: Crash with ::tls::socket
Type: Bug Version: Tip of Tcl 9
Submitter: kevin_walzer Created on: 2023-08-07 15:32:33
Subsystem: 25. Channel System Assigned To: kevin_walzer
Priority: 9 Immediate Severity: Critical
Status: Closed Last Modified: 2023-08-11 20:47:16
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2023-08-11 20:47:16
Description:
              	% package require http
		2.10b1
		% package require tls
		1.7.23
		% http::register https 443 [list ::tls::socket -autoservername true -require true ]
		443 {::tls::socket -autoservername true -require true}
		% set tok [http::geturl https://www.tcl.tk/]
		Segmentation fault: 11
		Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
		0   ???                           	               0x0 ???
		1   Tcl                           	       0x104d01be4 Tcl_UnregisterChannel + 348

The crash happens with the tcltls extension, but touches Tcl's core channel code, so I am opening this ticket under Tcl.
User Comments: kevin_walzer added on 2023-08-11 20:46:44:
This pointed me in the right direction. I was able to implement a close2Proc for Tcltls and the package now runs as expected in Tcl 9 without crashing. Thank you for your assistance.

kevin_walzer added on 2023-08-11 11:16:37:
Thank you for this insight - I will review the code base of tcltls in more detail to see if we can implement this. TIP 562 has a basic implementation example.

chrstphrchvz added on 2023-08-11 07:01:56:

TIP 562 means that the channel function closeProc() is deprecated, and close2Proc() is mandatory in Tcl 9. But TclTLS only implements a closeProc(), and not a close2Proc() (nor am I aware of any efforts to implement one). So TclClose() assumes close2Proc() is available, and crashes since the function pointer for it is NULL (which it was set to by memset() in Tls_ChannelType()).


kevin_walzer added on 2023-08-11 01:56:25:

So after running tclsh with symbols switched on, I have traced the crash to this call:

	  if ((flags & (TCL_READABLE | TCL_WRITABLE)) == 0) {
	    	return TclClose(interp, chan);
	    }

in tclIO.c, line 3636.

It's an invalid instruction fetch. Not sure what to do with this info or where to debug further.