View Ticket
2020-09-02
06:40 Ticket [e01f02a121] Segfault under wish at first tls::import, not under tclsh status still Open with 5 other changes artifact: a7a9eea528 user: anonymous
2020-09-01
09:44 Ticket [e01f02a121]: 6 changes artifact: bb8c278bf2 user: anonymous
2020-08-20
21:05 New ticket [e01f02a121]. artifact: 00a4ef8dc2 user: anonymous

Ticket Hash: e01f02a12180ac37cdb96ec16d0e03f89033cd77
Title: Segfault under wish at first tls::import, not under tclsh
Status: Open Type: Build Problem
Severity: Critical Priority: Immediate
Subsystem: Resolution: Open
Last Modified: 2020-09-02 06:40:21
Version Found In: 1.7.21
User Comments:
anonymous added on 2020-08-20 21:05:05:
Built TclTLS 1.7.21 on MacOS 10.6, against Tcl 8.6.10 and OpenSSL 1.1.1g.
Building went okay (once I figured out I need to make sure gen_dh_params 
finds up the right version of the openssl program), and make test works.

Then I try the following minimal https operation:

% package require tls
1.7.21
% package require http
2.9.1
% http::register https 443 [list ::tls::socket -autoservername true -require true -cafile /usr/local/ssl/cert.pem]
443 {::tls::socket -autoservername true -require true -cafile /usr/local/ssl/cert.pem}
% set tok [http::geturl https://www.tcl-lang.org/]

Under tclsh, that works fine. 
Under wish, it segfaults! Consistently.

More detailed breakdown, with debug build of tcltls:

----------- Begin output:
% package require tls
./tls.c:1779:Tls_Init():Called
./tls.c:1897:TlsLibInit():Called
./tlsBIO.c:53:BIO_new_tcl():BIO_new_tcl() called
./tlsBIO.c:66:BIO_new_tcl():Asked to setup a NULL state, just creating the initial configuration
1.7.21
% package require http
2.9.1
% http::register https 443 [list ::tls::socket -autoservername true -require true -cafile /usr/local/ssl/cert.pem]
443 {::tls::socket -autoservername true -require true -cafile /usr/local/ssl/cert.pem}
% set tok [http::geturl https://www.tcl-lang.org/]
./tls.c:759:ImportObjCmd():Called
./tls.c:1093:CTX_Init():Called
/usr/local/bin/wish: line 2: 67253 Segmentation fault      "$(dirname $0)/../../../Library/Frameworks/Tk.framework/Versions/8.6/Resources/Wish.app/Contents/MacOS/Wish" "$@"
----------- End output.

----------- Begin crash report:
Process:         Wish [67253]
Path:            /usr/local/bin/../../../Library/Frameworks/Tk.framework/Versions/8.6/Resources/Wish.app/Contents/MacOS/Wish
Identifier:      com.tcltk.wish
Version:         8.6.10 (8.6.10)
Code Type:       X86-64 (Native)
Parent Process:  sh [67251]

Date/Time:       2020-08-19 11:21:01.998 +0200
OS Version:      Mac OS X 10.6.8 (10K549)
Report Version:  6

Interval Since Last Report:          84517688 sec
Crashes Since Last Report:           808
Per-App Interval Since Last Report:  62722 sec
Per-App Crashes Since Last Report:   5
Anonymous UUID:                      1739C455-2439-487D-9ED0-2084ED6CAF3F

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib             	0x00007fff870ed7ee pthread_rwlock_wrlock + 50
1   libcrypto.1.1.dylib           	0x00000001150661ec CRYPTO_atomic_add + 44
2   libcrypto.1.1.dylib           	0x0000000114f77041 DH_up_ref + 33
3   libcrypto.1.1.dylib           	0x0000000114fff028 EVP_PKEY_set1_DH + 104
4   libssl.1.1.dylib              	0x0000000114d454f2 ssl3_ctx_ctrl + 1538
5   tcltls.dylib                  	0x00000001006351c3 ImportObjCmd + 2963 (.tls.c:1265)
6   Tcl                           	0x000000010018496f Tcl_ListMathFuncs + 3856
7   Tcl                           	0x000000010017e279 TclNRRunCallbacks + 58
8   Tcl                           	0x0000000100202fa3 Tcl_RecordAndEvalObj + 499
9   Tcl                           	0x0000000100203003 Tcl_RecordAndEval + 70
10  Tk                            	0x000000010002c91a TkPointerEvent + 19546
11  Tcl                           	0x000000010020d98c Tcl_NotifyChannel + 219
12  Tcl                           	0x0000000100272f3d Tcl_Sleep + 923
13  Tcl                           	0x0000000100226605 Tcl_ServiceEvent + 147
14  Tcl                           	0x00000001002268f5 Tcl_DoOneEvent + 314
15  Tk                            	0x000000010001ee29 Tk_MainLoop + 24
16  Tk                            	0x000000010002d24a Tk_MainEx + 2067
17  Wish                          	0x0000000100005141 0x100000000 + 20801
18  Wish                          	0x000000010000507c 0x100000000 + 20604

Thread 1:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib             	0x00007fff870a5c0a kevent + 10
1   libSystem.B.dylib             	0x00007fff870a7add _dispatch_mgr_invoke + 154
2   libSystem.B.dylib             	0x00007fff870a77b4 _dispatch_queue_invoke + 185
3   libSystem.B.dylib             	0x00007fff870a72de _dispatch_worker_thread2 + 252
4   libSystem.B.dylib             	0x00007fff870a6c08 _pthread_wqthread + 353
5   libSystem.B.dylib             	0x00007fff870a6aa5 start_wqthread + 13

Thread 2:
0   libSystem.B.dylib             	0x00007fff870d0932 select$DARWIN_EXTSN + 10
1   Tcl                           	0x0000000100273f38 Tcl_InitNotifier + 1582
2   libSystem.B.dylib             	0x00007fff870c5fd6 _pthread_start + 331
3   libSystem.B.dylib             	0x00007fff870c5e89 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x00007fff5fbfc5fc
  rdi: 0x0000000000000000  rsi: 0x0000000000000001  rbp: 0x00007fff5fbfc5b0  rsp: 0x00007fff5fbfc570
   r8: 0x0000000114f14aa0   r9: 0x00000001004fc0a4  r10: 0x0000000000000015  r11: 0x0000000100495c80
  r12: 0x00000001004977a8  r13: 0x0000000000000001  r14: 0x00007fff70c83cc0  r15: 0x0000000100878a10
  rip: 0x00007fff870ed7ee  rfl: 0x0000000000010246  cr2: 0x0000000000000000

Binary Images:
       0x100000000 -        0x100005fff +Wish 8.6.10 (8.6.10) <0011BD8F-1A02-680C-2CDB-27DAE0B3D210> /Library/Frameworks/Tk.framework/Versions/8.6/Resources/Wish.app/Contents/MacOS/Wish
       0x100008000 -        0x10012efff +Tk 8.6.10 (8.6.10) <46A77D75-596C-688F-8463-D94D9DD8DAA8> /Library/Frameworks/Tk.framework/Versions/8.6/Tk
       0x10016c000 -        0x1002bffe7 +Tcl 8.6.10 (8.6.10) <244BB429-D766-491A-1BC8-618C09B682CC> /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl
       0x100631000 -        0x100641fff +tcltls.dylib ??? (???) <B8E9509B-C6B2-6F23-2AE6-08649614054C> /Users/lars/G4-kopia/Rest/Installerare/tcltls-1.7.21/tcltls.dylib
       0x114d32000 -        0x114da0fef +libssl.1.1.dylib 1.1.0 (compatibility 1.1.0) <49C12534-82D6-1671-580E-A4F0C8E32536> /usr/local/lib/libssl.1.1.dylib
       0x114f00000 -        0x11512d0b7 +libcrypto.1.1.dylib 1.1.0 (compatibility 1.1.0) <3157E172-B9F7-F408-BAB8-E73E4A32289D> /usr/local/lib/libcrypto.1.1.dylib
    0x7fff5fc00000 -     0x7fff5fc3be0f  dyld 132.1 (???) <29DECB19-0193-2575-D838-CF743F0400B2> /usr/lib/dyld
    0x7fff800dc000 -     0x7fff8010dfff  libGLImage.dylib ??? (???) <562565E1-AA65-FE96-13FF-437410C886D0> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x7fff801da000 -     0x7fff80258ff7  com.apple.CoreText 151.13 (???) <5C6214AD-D683-80A8-86EB-328C99B75322> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
    0x7fff80259000 -     0x7fff8026dfff  libGL.dylib ??? (???) <2ECE3B0F-39E1-3938-BF27-7205C6D0358B> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x7fff8026e000 -     0x7fff80279ff7  com.apple.speech.recognition.framework 3.11.1 (3.11.1) <3D65E89B-FFC6-4AAF-D5CC-104F967C8131> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
    0x7fff8037e000 -     0x7fff803c5ff7  com.apple.coreui 2 (114) <923E33CC-83FC-7D35-5603-FB8F348EE34B> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
    0x7fff803c6000 -     0x7fff8047cff7  libobjc.A.dylib 227.0.0 (compatibility 1.0.0) <03140531-3B2D-1EBA-DA7F-E12CC8F63969> /usr/lib/libobjc.A.dylib
    0x7fff8047d000 -     0x7fff8063cfff  com.apple.ImageIO.framework 3.0.6 (3.0.6) <92882FD3-CB3F-D0BE-DDDA-43B4BEE10F58> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x7fff806b3000 -     0x7fff8073ffef  SecurityFoundation ??? (???) <3F1F2727-C508-3630-E2C1-38361841FCE4> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff807a3000 -     0x7fff807ebff7  libvDSP.dylib 268.0.1 (compatibility 1.0.0) <98FC4457-F405-0262-00F7-56119CA107B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff807ec000 -     0x7fff80c2ffef  libLAPACK.dylib 219.0.0 (compatibility 1.0.0) <57D38705-6F21-2A82-F3F6-03CFFF214775> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff80c74000 -     0x7fff80c74ff7  com.apple.Carbon 150 (152) <FA427C37-CF97-6773-775D-4F752ED68581> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
    0x7fff80c75000 -     0x7fff80cb6fef  com.apple.QD 3.36 (???) <5DC41E81-32C9-65B2-5528-B33E934D5BB4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x7fff80cb7000 -     0x7fff80d0dfe7  libTIFF.dylib ??? (???) <2DBEC120-DAA7-3789-36A2-A205BCDF2D72> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x7fff80d49000 -     0x7fff80d7cff7  libTrueTypeScaler.dylib ??? (???) <B7BA8104-FA18-39A2-56E1-922EE7A660AC> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libTrueTypeScaler.dylib
    0x7fff80e7e000 -     0x7fff80e84ff7  com.apple.CommerceCore 1.0 (9.1) <3691E9BA-BCF4-98C7-EFEC-78DA6825004E> /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/CommerceCore.framework/Versions/A/CommerceCore
    0x7fff80e85000 -     0x7fff80ecfff7  com.apple.Metadata 10.6.3 (507.15) <DE238BE4-5E22-C4D5-CF5C-3D50FDEE4701> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff80f88000 -     0x7fff81684ff7  com.apple.CoreGraphics 1.545.0 (???) <58D597B1-EB3B-710E-0B8C-EC114D54E11B> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x7fff81e22000 -     0x7fff81f3cfff  libGLProgrammability.dylib ??? (???) <D1650AED-02EF-EFB3-100E-064C7F018745> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
    0x7fff81fa0000 -     0x7fff82040fff  com.apple.LaunchServices 362.3 (362.3) <B90B7C31-FEF8-3C26-BFB3-D8A48BD2C0DA> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff82041000 -     0x7fff823defe7  com.apple.QuartzCore 1.6.3 (227.37) <16DFF6CD-EA58-CE62-A1D7-5F6CE3D066DD> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
    0x7fff824a0000 -     0x7fff824a1ff7  com.apple.TrustEvaluationAgent 1.1 (1) <5952A9FA-BC2B-16EF-91A7-43902A5C07B6> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff82520000 -     0x7fff82539fff  com.apple.CFOpenDirectory 10.6 (10.6) <401557B1-C6D1-7E1A-0D7E-941715C37BFA> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff827b7000 -     0x7fff82879fe7  libFontParser.dylib ??? (???) <EF06F16C-0CC9-B4CA-7BD9-0A97FA967340> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
    0x7fff8287a000 -     0x7fff829f1fe7  com.apple.CoreFoundation 6.6.6 (550.44) <BB4E5158-E47A-39D3-2561-96CB49FA82D4> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff82b65000 -     0x7fff82e99fef  com.apple.CoreServices.CarbonCore 861.39 (861.39) <1386A24D-DD15-5903-057E-4A224FAF580B> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff836db000 -     0x7fff8371eff7  libRIP.A.dylib 545.0.0 (compatibility 64.0.0) <5FF3D7FD-84D8-C5FA-D640-90BB82EC651D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
    0x7fff8371f000 -     0x7fff8375afff  com.apple.AE 496.5 (496.5) <208DF391-4DE6-81ED-C697-14A2930D1BC6> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff83a81000 -     0x7fff83a81ff7  com.apple.CoreServices 44 (44) <DC7400FB-851E-7B8A-5BF6-6F50094302FB> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff83ac2000 -     0x7fff83ac4fff  libRadiance.dylib ??? (???) <BF694EE5-6FDA-553A-CC89-F7135618E9C7> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x7fff83b4f000 -     0x7fff83dd1fff  com.apple.Foundation 6.6.8 (751.63) <E10E4DB4-9D5E-54A8-3FB6-2A82426066E4> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff83e0a000 -     0x7fff83e19fff  com.apple.NetFS 3.2.2 (3.2.2) <7CCBD70E-BF31-A7A7-DB98-230687773145> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff83e1a000 -     0x7fff83e6dff7  com.apple.HIServices 1.8.3 (???) <F6E0C7A7-C11D-0096-4DDA-2C77793AA6CD> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x7fff83e73000 -     0x7fff83f2cfff  libsqlite3.dylib 9.6.0 (compatibility 9.0.0) <2C5ED312-E646-9ADE-73A9-6199A2A43150> /usr/lib/libsqlite3.dylib
    0x7fff8449b000 -     0x7fff844b6ff7  com.apple.openscripting 1.3.1 (???) <9D50701D-54AC-405B-CC65-026FCB28258B> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
    0x7fff844b7000 -     0x7fff844d7fff  com.apple.DirectoryService.Framework 3.6 (621.16) <0ED4A74A-F8FB-366D-6588-F13EA397326F> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
    0x7fff844df000 -     0x7fff845c4fef  com.apple.DesktopServices 1.5.11 (1.5.11) <39FAA3D2-6863-B5AB-AED9-92D878EA2438> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
    0x7fff8466a000 -     0x7fff846bfff7  com.apple.framework.familycontrols 2.0.2 (2020) <8807EB96-D12D-8601-2E74-25784A0DE4FF> /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls
    0x7fff84726000 -     0x7fff84772fff  libauto.dylib ??? (???) <F7221B46-DC4F-3153-CE61-7F52C8C293CF> /usr/lib/libauto.dylib
    0x7fff84773000 -     0x7fff8479bfff  com.apple.DictionaryServices 1.1.2 (1.1.2) <E9269069-93FA-2B71-F9BA-FDDD23C4A65E> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff8479c000 -     0x7fff8479cff7  com.apple.ApplicationServices 38 (38) <0E2FC75E-2BE2-D04D-CA78-76E38A89DD30> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
    0x7fff8479d000 -     0x7fff847acfef  com.apple.opengl 1.6.14 (1.6.14) <ECAE2D12-5BE3-46E7-6EE5-563B80B32A3E> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x7fff848f9000 -     0x7fff84d40fef  com.apple.RawCamera.bundle 3.7.1 (570) <5AFA87CA-DC3D-F84E-7EA1-6EABA8807766> /System/Library/CoreServices/RawCamera.bundle/Contents/MacOS/RawCamera
    0x7fff85e3c000 -     0x7fff8613afff  com.apple.HIToolbox 1.6.5 (???) <AD1C18F6-51CB-7E39-35DD-F16B1EB978A8> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7fff8613b000 -     0x7fff861d5fff  com.apple.ApplicationServices.ATS 275.19 (???) <2DE8987F-4563-4D8E-45C3-2F6F786E120D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x7fff86382000 -     0x7fff86407ff7  com.apple.print.framework.PrintCore 6.3 (312.7) <CDFE82DD-D811-A091-179F-6E76069B432D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x7fff86421000 -     0x7fff86422fff  liblangid.dylib ??? (???) <D0666597-B331-C43C-67BB-F2E754079A7A> /usr/lib/liblangid.dylib
    0x7fff86423000 -     0x7fff86429ff7  IOSurface ??? (???) <8E302BB2-0704-C6AB-BD2F-C2A6C6A2E2C3> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
    0x7fff8642a000 -     0x7fff8644fff7  com.apple.CoreVideo 1.6.2 (45.6) <E138C8E7-3CB6-55A9-0A2C-B73FE63EA288> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
    0x7fff865cd000 -     0x7fff865d2ff7  com.apple.CommonPanels 1.2.4 (91) <8B088D78-E508-6622-E477-E34C22CF2F67> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
    0x7fff865ee000 -     0x7fff865f3fff  libGFXShared.dylib ??? (???) <6BBC351E-40B3-F4EB-2F35-05BDE52AF87E> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
    0x7fff865f4000 -     0x7fff865f4ff7  com.apple.Accelerate 1.6 (Accelerate 1.6) <15DF8B4A-96B2-CB4E-368D-DEC7DF6B62BB> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff865f5000 -     0x7fff86674fe7  com.apple.audio.CoreAudio 3.2.6 (3.2.6) <79E256EB-43F1-C7AA-6436-124A4FFB02D0> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x7fff86687000 -     0x7fff866d6ff7  com.apple.DirectoryService.PasswordServerFramework 6.1 (6.1) <0731C40D-71EF-B417-C83B-54C3527A36EA> /System/Library/PrivateFrameworks/PasswordServer.framework/Versions/A/PasswordServer
    0x7fff866d7000 -     0x7fff866ebff7  com.apple.speech.synthesis.framework 3.10.35 (3.10.35) <574C1BE0-5E5E-CCAF-06F8-92A69CB2892D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x7fff866f8000 -     0x7fff867d5fff  com.apple.vImage 4.1 (4.1) <C3F44AA9-6F71-0684-2686-D3BBC903F020> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff867d6000 -     0x7fff867f7fff  libresolv.9.dylib 41.1.0 (compatibility 1.0.0) <9410EC7F-4D24-6740-AFEE-90405750FAD7> /usr/lib/libresolv.9.dylib
    0x7fff8680b000 -     0x7fff86820ff7  com.apple.LangAnalysis 1.6.6 (1.6.6) <1AE1FE8F-2204-4410-C94E-0E93B003BEDA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x7fff86821000 -     0x7fff86aaaff7  com.apple.security 6.1.2 (55002) <D224882B-D57B-83AF-3781-548BCEACB327> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff86bd9000 -     0x7fff86c9afef  com.apple.ColorSync 4.6.8 (4.6.8) <7DF1D175-6451-51A2-DBBF-40FCA78C0D2C> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x7fff86c9b000 -     0x7fff86ca9ff7  libkxld.dylib ??? (???) <8145A534-95CC-9F3C-B78B-AC9898F38C6F> /usr/lib/system/libkxld.dylib
    0x7fff86caa000 -     0x7fff86cadfff  com.apple.help 1.3.2 (41.1) <BD1B0A22-1CB8-263E-FF85-5BBFDE3660B9> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
    0x7fff86cae000 -     0x7fff86ccffe7  libPng.dylib ??? (???) <D8EC7740-EE32-865A-2F75-C9EDE2135510> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x7fff86cd0000 -     0x7fff86d3afe7  libvMisc.dylib 268.0.1 (compatibility 1.0.0) <AF0EA96D-000F-8C12-B952-CB7E00566E08> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff8708c000 -     0x7fff8724dfef  libSystem.B.dylib 125.2.11 (compatibility 1.0.0) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib
    0x7fff8724e000 -     0x7fff87275ff7  libJPEG.dylib ??? (???) <08758593-6436-B29E-1DA8-F15597835EC1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x7fff87276000 -     0x7fff87277ff7  com.apple.audio.units.AudioUnit 1.6.7 (1.6.7) <49B723D1-85F8-F86C-2331-F586C56D68AF> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
    0x7fff8741a000 -     0x7fff87427fe7  libCSync.A.dylib 545.0.0 (compatibility 64.0.0) <1C35FA50-9C70-48DC-9E8D-2054F7A266B1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
    0x7fff875e9000 -     0x7fff87666fef  libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
    0x7fff87667000 -     0x7fff876a8fff  com.apple.SystemConfiguration 1.10.8 (1.10.2) <78D48D27-A9C4-62CA-2803-D0BBED82855A> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff87713000 -     0x7fff87773fe7  com.apple.framework.IOKit 2.0 (???) <4F071EF0-8260-01E9-C641-830E582FA416> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff87774000 -     0x7fff87831fff  com.apple.CoreServices.OSServices 359.2 (359.2) <BBB8888E-18DE-5D09-3C3A-F4C029EC7886> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff878fa000 -     0x7fff87ab8fff  libicucore.A.dylib 40.0.0 (compatibility 1.0.0) <97A75BFB-0DB6-6F44-36B0-97B7F7208ABB> /usr/lib/libicucore.A.dylib
    0x7fff87c9c000 -     0x7fff87cdafe7  libFontRegistry.dylib ??? (???) <395D7C0D-36B5-B353-0DC8-51ABC0B1C030> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
    0x7fff87d37000 -     0x7fff88731ff7  com.apple.AppKit 6.6.8 (1038.36) <4CFBE04C-8FB3-B0EA-8DDB-7E7D10E9D251> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7fff88732000 -     0x7fff88848ff7  libxml2.2.dylib 10.3.0 (compatibility 10.0.0) <3814FCF9-92B9-A6AB-E76A-F7021894AA3F> /usr/lib/libxml2.2.dylib
    0x7fff88849000 -     0x7fff888fefe7  com.apple.ink.framework 1.3.3 (107) <8C36373C-5473-3A6A-4972-BC29D504250F> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
    0x7fff8894a000 -     0x7fff89154fe7  libBLAS.dylib 219.0.0 (compatibility 1.0.0) <2F26CDC7-DAE9-9ABE-6806-93BBBDA20DA0> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff89398000 -     0x7fff893e1fef  libGLU.dylib ??? (???) <B0F4CA55-445F-E901-0FCF-47B3B4BAE6E2> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x7fff89583000 -     0x7fff89587ff7  libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
    0x7fff8958e000 -     0x7fff89662fe7  com.apple.CFNetwork 454.12.4 (454.12.4) <C83E2BA1-1818-B3E8-5334-860AD21D1C80> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff8975c000 -     0x7fff8975cff7  com.apple.vecLib 3.6 (vecLib 3.6) <96FB6BAD-5568-C4E0-6FA7-02791A58B584> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff89798000 -     0x7fff89798ff7  com.apple.Accelerate.vecLib 3.6 (vecLib 3.6) <4CCE5D69-F1B3-8FD3-1483-E0271DB2CCF3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff89b74000 -     0x7fff89c04fff  com.apple.SearchKit 1.3.0 (1.3.0) <45BA1053-9196-3C2F-2421-AFF5E09627CC> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff89e43000 -     0x7fff89e47ff7  libCGXType.A.dylib 545.0.0 (compatibility 64.0.0) <DB710299-B4D9-3714-66F7-5D2964DE585B> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGXType.A.dylib
    0x7fff89eb1000 -     0x7fff89eb7ff7  com.apple.DiskArbitration 2.3 (2.3) <AAB5CC56-334A-3C60-3C27-54E8F34D754E> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff89ec6000 -     0x7fff89ffbfff  com.apple.audio.toolbox.AudioToolbox 1.6.7 (1.6.7) <F4814A13-E557-59AF-30FF-E62929367933> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x7fff89ffc000 -     0x7fff8a012fe7  com.apple.MultitouchSupport.framework 207.11 (207.11) <8233CE71-6F8D-8B3C-A0E1-E123F6406163> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
    0x7fff8a013000 -     0x7fff8a01afff  com.apple.OpenDirectory 10.6 (10.6) <4FF6AD25-0916-B21C-9E88-2CC42D90EAC7> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff8a01b000 -     0x7fff8a032fff  com.apple.ImageCapture 6.1 (6.1) <79AB2131-2A6C-F351-38A9-ED58B25534FD> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
    0x7fff8a056000 -     0x7fff8a106fff  edu.mit.Kerberos 6.5.11 (6.5.11) <085D80F5-C9DC-E252-C21B-03295E660C91> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
    0x7fff8a111000 -     0x7fff8a13cff7  libxslt.1.dylib 3.24.0 (compatibility 3.0.0) <3630A97F-55C1-3F34-CA63-3847653C9645> /usr/lib/libxslt.1.dylib
    0x7fff8a13d000 -     0x7fff8a160fff  com.apple.opencl 12.3.6 (12.3.6) <42FA5783-EB80-1168-4015-B8C68F55842F> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
    0x7fff8a17d000 -     0x7fff8a182fff  libGIF.dylib ??? (???) <3BAD0DE8-8151-68B0-2244-A4541C738972> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x7fff8a183000 -     0x7fff8a199fef  libbsm.0.dylib ??? (???) <0321D32C-9FE1-3919-E03E-2530A0C1191B> /usr/lib/libbsm.0.dylib
    0x7fff8a1f9000 -     0x7fff8a1fcff7  libCoreVMClient.dylib ??? (???) <75819794-3B7A-8944-D004-7EA6DD7CE836> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
    0x7fff8a1fd000 -     0x7fff8a237fff  libcups.2.dylib 2.8.0 (compatibility 2.0.0) <4F2A4397-89BD-DEAC-4971-EE838FFA0964> /usr/lib/libcups.2.dylib
    0x7fff8a238000 -     0x7fff8a24afe7  libsasl2.2.dylib 3.15.0 (compatibility 3.0.0) <30FE378B-99FE-8C7C-06D0-A3AA0A0A70D4> /usr/lib/libsasl2.2.dylib
    0x7fff8a267000 -     0x7fff8a269fff  com.apple.print.framework.Print 6.1 (237.1) <CA8564FB-B366-7413-B12E-9892DA3C6157> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
    0x7fff8a4b1000 -     0x7fff8a5d0ff7  libcrypto.0.9.8.dylib 0.9.8 (compatibility 0.9.8) <0CE8D59B-D0C7-1DCE-3654-37F27F61BEFA> /usr/lib/libcrypto.0.9.8.dylib
    0x7fff8a67b000 -     0x7fff8a7b9fff  com.apple.CoreData 102.1 (251) <9DFE798D-AA52-6A9A-924A-DA73CB94D81A> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7fff8a7ba000 -     0x7fff8a7cbff7  libz.1.dylib 1.2.3 (compatibility 1.0.0) <97019C74-161A-3488-41EC-A6CA8738418C> /usr/lib/libz.1.dylib
    0x7fff8a7d5000 -     0x7fff8a7d8ff7  com.apple.securityhi 4.0 (36638) <AEF55AF1-54D3-DB8D-27A7-E16192E0045A> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
    0x7fff8a7d9000 -     0x7fff8a7d9ff7  com.apple.Cocoa 6.6 (???) <C69E895A-1C66-3DA9-5F63-8BE85DB9C4E1> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
    0x7fffffe00000 -     0x7fffffe01fff  libSystem.B.dylib ??? (???) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib

Model: MacBookPro7,1, BootROM MBP71.0039.B0B, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.62f7
Graphics: NVIDIA GeForce 320M, NVIDIA GeForce 320M, PCI, 256 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.10.131.42.4)
Bluetooth: Version 2.4.5f3, 2 service, 12 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Serial ATA Device: HL-DT-ST DVDRW  GS23N
USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x24600000 / 2
USB Device: USB to ATA/ATAPI Bridge, 0x357d, 0x7788, 0x26400000 / 3
USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 0x26100000 / 2
USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x06600000 / 4
USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 0x06610000 / 5
USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x06500000 / 3
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0237, 0x06300000 / 2
----------- End crash report.

As far as I can tell, what is going on here is that OpenSSL wants to 
increase the refcount on those darn DH params (or maybe part thereof), 
seeks to acquire a lock on that refcount, and then crashes.

It's worth noticing openssl-1.1.1g/include/internal/refcount.h contains 
a number of implementations of the CRYPTO_UP_REF and CRYPTO_DOWN_REF 
operations, most of which don't seem to use the final lock parameter 
of these macros, but my compiler ends up using the very last definition, 
which calls various pthread_??? functions with that as argument, so 
someone forgetting to initialise that lock could handily explain what 
is going wrong here. 
Whether that error would be on the part of OpenSSL or TclTLS, however, 
I couldn't say. But all OpenSSL tests pass.

anonymous (claiming to be lars_h) added on 2020-09-01 09:44:20:
Okay, I think I've diagnosed this now, though I don't know how to fix it.
There doesn't seem to be an error in the TclTLS source code as such, so
the fix is probably rather to adjust the build process -- figure out the
right options to pass, and it should work. However I suspect TclTLS still 
needs improving because of this issue, since it does seem to be a more 
general vulnerability; it should be easy to make a hardened build, even 
if one does not make it the default.

In short, the problem is that under Wish I'm getting two different 
versions of libcrypto loaded, and the dynamic linker is making TclTLS 
call some functions from one version and other functions from the other; 
since they are rather far from being binary compatible, a crash is only 
to be expected. tclsh avoids the problem by not loading the first version 
of libcrypto, so that all calls go to the second version against which 
TclTLS was actually built, *but*: should tclsh load any other library 
with a dependence upon the first libcrypto version before it loads TclTLS 
then the problem will surface also there. Right now TclTLS is vulnerable 
in that it depends on other parties not doing things it hadn't expected, 
instead of making sure that it gets what it requires.

It might be argued that having different versions of a library in the 
same process is a big no-no, and that the fix is to update everything to 
use the same most recent version, but that is frankly impossible; the 
old libcrypto is being brought in by some system library (don't know 
which one, but the one next to it in the list is called TrustEvaluationAgent,
which seems a plausible user) and this ain't linux -- we can't hope to 
go recompiling those. Moreover it might be remarked that the (long) list 
of shared libraries Wish loads includes a decade-old libsqlite3.dylib, 
but that has never been a problem for tclsqlite3, presumably because that 
links statically with the sqlite3 library. I see no reason why TclTLS 
couldn't have an option to do the same, but I cannot find anything in 
the documentation to that effect.

Indeed, the documentation for OpenSSL 1.0.x strongly recommends linking 
statically against the library (for security reasons), though the 
OpenSSL 1.1.x documentation does not make this point (that I can see). 
I have however only been able to build TclTLS to link against the dylibs.

Much longer, my investigation was as follows:

I saw the program crash in pthread_rwlock_wrlock, called from the 
	SSL_CTX_set_tmp_dh(ctx, dh);
line in CTX_Init (tls.c around line 1260, but I've done some hacking 
to debug so my line numbers are off), with a 
  KERN_INVALID_ADDRESS at 0x0000000000000000
So... a NULL pointer dereferencing. It turns out the pointer in 
question is dh->lock up in tls.c (or it would be, had the DH type not 
been opaque in tls.c, but it is a field in the struct that dh points to). 
What SSL_CTX_set_tmp_dh is doing at the time of the crash is that it 
is adjusting the refcount of those DH parameters, and the lock in 
question is protecting that refcount.

The CRYPTO_UP_REF operation being used does have something like four 
different implementations, many of which don't need this lock at all 
(but not the last resort implementation via pthreads I end up with), 
so it would not be outrageous to suspect a bug in libcrypto where this 
field never gets initialised, but that is not what is going on.

Some hacking to insert statements printing the value of dh->lock 
reveals that it is indeed NULL when run under Wish, but non-NULL 
when run under tclsh. Some more hacking in dh_params.h reveals that 
this is what that struct is like already when DH_new returns it. 
This could still be a matter of uninitialised memory just happening 
to have a fortuitous value in tclsh but not Wish, though to be sure 
one needs to see what DH_new (or rather the underlying DH_new_method, 
both living in openssl-1.1.1g/crypto/dh/dh_lib.c) is doing.

This is where things get weird, because from RTFS that function has 
an explicit check whether lock is NULL, and will return NULL for the 
dh pointer if it is. Yet when run, DH_new is returning a non-NULL 
pointer for dh such that dh->lock is NULL. This should not happen. 
Might some later instruction in DH_new_method be overwriting the lock 
with garbage? Only way to tell is to bring out a debugger. That's 
where things get *really* weird.

(In retrospect, working with this issue the first time one uses gdb 
is probably not ideal, but hey, I've learnt some gdb now! Good for me.)

For some reason, gdb refuses to step into the DH_new function, 
complaining about there not being line number information available. 
In retrospect this could have been a clue, but I spend a lot of time 
fiddling with compiler options for debug information, hoping that this 
will do the trick. It might even have helped a bit, but eventually I'm 
down to stepping at the machine code level. The gdb list command is not 
showing anything that makes sense, but the disassemble command is my 
friend, once I refresh myself on the memnonics. What I see is … 
plausibly the DH_new_method function, but it looks like it has been 
optimised to hell and back, and indeed the crucial CRYPTO_THREAD_lock_new 
call is missing. But this libcrypto was compiled with -O0, so why would 
it be optimised??

Indeed, when running gdb on just libcrypto.1.1.dylib I get a disassembly 
looking the way I might expect (even overly roundabout). Even more 
strange, I get the same listing when I ask the gdb debugging Wish to 
  disassemble DH_new_method
So why isn't *that* the code that this process is running?? Then it hits 
me: the addresses don't match. The good DH_new_method is at 
0x0000000114e7bfe0, but the one that gets called is at 0x00007fff8a4e6e90. 
gdb says both are called DH_new_method, but 0x00007fff8a4e6e90 is in 
libcrypto.0.9.8.dylib, whereas 0x0000000114e7bfe0 is in 
libcrypto.1.1.dylib, just like call that invokes the CRYPTO_UP_REF 
operation. Mystery solved, to some extent.

Now I only need to figure out how to make TclTLS bind to the right 
instances of these symbols. It would help getting some input from 
people who actually know how all these things are supposed to fit 
together, instead of having to guess while randomly poking.

anonymous (claiming to be lars_h) added on 2020-09-02 06:40:21:
Huh, that was easier to solve than I thought.

First, the easiest way of demonstrating that the symbol bindings 
are wrong is to set the environment variable DYLD_PRINT_BINDINGS. 
With that, and the default linker flags for shared-tcltls.dylib, 
we get (in the vicinity of DH_new):

dyld: lazy forcedbind: tcltls.dylib:0x100742118 = libcrypto.0.9.8.dylib:_DH_free, *0x100742118 = 0x7FFF8A4E6D50
dyld: lazy forcedbind: tcltls.dylib:0x100742120 = libcrypto.0.9.8.dylib:_DH_new, *0x100742120 = 0x7FFF8A4E70D0
dyld: lazy forcedbind: tcltls.dylib:0x100742128 = libcrypto.1.1.dylib:_DH_set0_pqg, *0x100742128 = 0x114E7C52A
dyld: lazy forcedbind: tcltls.dylib:0x100742130 = libcrypto.0.9.8.dylib:_ERR_clear_error, *0x100742130 = 0x7FFF8A52DB30
dyld: lazy forcedbind: tcltls.dylib:0x100742138 = libcrypto.0.9.8.dylib:_ERR_get_error, *0x100742138 = 0x7FFF8A52DB10
dyld: lazy forcedbind: tcltls.dylib:0x100742140 = libcrypto.0.9.8.dylib:_ERR_reason_error_string, *0x100742140 = 0x7FFF8A550810
dyld: lazy forcedbind: tcltls.dylib:0x100742148 = libcrypto.0.9.8.dylib:_EVP_PKEY_assign, *0x100742148 = 0x7FFF8A4BDBA0
dyld: lazy forcedbind: tcltls.dylib:0x100742150 = libcrypto.0.9.8.dylib:_EVP_PKEY_free, *0x100742150 = 0x7FFF8A4BDAD0
dyld: lazy forcedbind: tcltls.dylib:0x100742158 = libcrypto.0.9.8.dylib:_EVP_PKEY_new, *0x100742158 = 0x7FFF8A4BD410
dyld: lazy forcedbind: tcltls.dylib:0x100742160 = libcrypto.0.9.8.dylib:_EVP_md5, *0x100742160 = 0x7FFF8A4F6F50
dyld: lazy forcedbind: tcltls.dylib:0x100742168 = libcrypto.0.9.8.dylib:_EVP_sha1, *0x100742168 = 0x7FFF8A55B140
dyld: lazy forcedbind: tcltls.dylib:0x100742170 = libcrypto.1.1.dylib:_OPENSSL_init_crypto, *0x100742170 = 0x114F10356
dyld: lazy forcedbind: tcltls.dylib:0x100742178 = libssl.1.1.dylib:_OPENSSL_init_ssl, *0x100742178 = 0x114D244F9
dyld: lazy forcedbind: tcltls.dylib:0x100742180 = libcrypto.1.1.dylib:_OPENSSL_sk_num, *0x100742180 = 0x114F7B653
dyld: lazy forcedbind: tcltls.dylib:0x100742188 = libcrypto.1.1.dylib:_OPENSSL_sk_value, *0x100742188 = 0x114F7B67B

Further up there are a lot more binding to libcrypto.1.1.dylib, 
so it's not as much 0.9.8 overall as this excerpt might suggest, 
but any amount of schizophrenic bindings is a crash waiting to happen.

Now why are the bindings done in this crazy way? It turns out the 
standard LDFLAGS include
   -flat_namespace 
which literally means "don't pay attention to what library a symbol 
should be from, just grab the first symbol with the right name that 
comes along". Pretty much the source of these troubles, isn't it? 
Indeed, if removing that flag and the subsequent -undefined suppress 
from the LDFLAGS, tcltls still builds just fine, and the bindings 
now look sane:

dyld: lazy forcedbind: tcltls.dylib:0x100642118 = libcrypto.1.1.dylib:_DH_free, *0x100642118 = 0x114F7C221
dyld: lazy forcedbind: tcltls.dylib:0x100642120 = libcrypto.1.1.dylib:_DH_new, *0x100642120 = 0x114F7BFD0
dyld: lazy forcedbind: tcltls.dylib:0x100642128 = libcrypto.1.1.dylib:_DH_set0_pqg, *0x100642128 = 0x114F7C52A
dyld: lazy forcedbind: tcltls.dylib:0x100642130 = libcrypto.1.1.dylib:_ERR_clear_error, *0x100642130 = 0x114FE1ACE
dyld: lazy forcedbind: tcltls.dylib:0x100642138 = libcrypto.1.1.dylib:_ERR_get_error, *0x100642138 = 0x114FE1BD4
dyld: lazy forcedbind: tcltls.dylib:0x100642140 = libcrypto.1.1.dylib:_ERR_reason_error_string, *0x100642140 = 0x114FE26A1
dyld: lazy forcedbind: tcltls.dylib:0x100642148 = libcrypto.1.1.dylib:_EVP_PKEY_assign, *0x100642148 = 0x11500686E
dyld: lazy forcedbind: tcltls.dylib:0x100642150 = libcrypto.1.1.dylib:_EVP_PKEY_free, *0x100642150 = 0x115006DE8
dyld: lazy forcedbind: tcltls.dylib:0x100642158 = libcrypto.1.1.dylib:_EVP_PKEY_new, *0x100642158 = 0x115006002
dyld: lazy forcedbind: tcltls.dylib:0x100642160 = libcrypto.1.1.dylib:_EVP_md5, *0x100642160 = 0x115002E37
dyld: lazy forcedbind: tcltls.dylib:0x100642168 = libcrypto.1.1.dylib:_EVP_sha1, *0x100642168 = 0x11500353E
dyld: lazy forcedbind: tcltls.dylib:0x100642170 = libcrypto.1.1.dylib:_OPENSSL_init_crypto, *0x100642170 = 0x115010356
dyld: lazy forcedbind: tcltls.dylib:0x100642178 = libssl.1.1.dylib:_OPENSSL_init_ssl, *0x100642178 = 0x114E244F9
dyld: lazy forcedbind: tcltls.dylib:0x100642180 = libcrypto.1.1.dylib:_OPENSSL_sk_num, *0x100642180 = 0x11507B653
dyld: lazy forcedbind: tcltls.dylib:0x100642188 = libcrypto.1.1.dylib:_OPENSSL_sk_value, *0x100642188 = 0x11507B67B

Not a 0.9.8 in sight, and now I can have wish eval
   http::geturl https://www.tcl-lang.org/
without segfaulting. Promising, but maybe a proper fix should rather 
be in the Tcl build system, since that is what contributes the 
-flat_namespace. Time for another bug report, I suppose.