Skip to content
Tcl Source Code View Ticket
Login

View Ticket

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

Crash with ::tls::socket

Closed / Fixedd1554fca55e91bacf9a719eb87cbd6e8a3f0df78Created 3 years agoUpdated 3 years ago
Descriptionplain2023-08-07 15:32:33
              	% 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.
kevin_walzer Ticket [d1554fca55]: 3 changes [History diff]2023-08-07 15:34:57
kevin_walzer Ticket [d1554fca55]: 3 changes [History diff]2023-08-07 15:35:32
kevin_walzermarkdown2023-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.

chrstphrchvzwiki2023-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_walzerplain2023-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.
kevin_walzerplain2023-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 Closed ticket [d1554fca55]. [History diff]2023-08-11 20:47:16
Log in (anonymous is fine) to add a comment.