macOS : crash when building Tcl in develop mode
Hi, I would like to use Tcl in develop mode in order to print symbol and line numbers when a crash occur (Tk is crashing on macOS26 and I would like to report it). so on macOS I'm compiling Tcl like this: make -j 4 -C macosx develop CFLAGS="-fno-omit-frame-pointer -Og -g" $SUDO make -C macosx install-develop when I start my app it does not even start and crash like that: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x18bac2388 __pthread_kill + 8 1 libsystem_pthread.dylib 0x18bafb88c pthread_kill + 296 2 libsystem_c.dylib 0x18ba04a3c abort + 124 3 libsystem_c.dylib 0x18ba03c70 __assert_rtn + 284 4 Tcl 0x10116cda4 <deduplicated_symbol> + 40 5 Tcl 0x101139fdc TclZipfs_TclLibrary + 4 (tclZipfs.c:4380) [inlined] 6 Tcl 0x101139fdc ZipFSTclLibraryObjCmd + 140 (tclZipfs.c:4413) 7 Tcl 0x10102fcf4 Dispatch + 104 (tclBasic.c:4640) 8 Tcl 0x10102dc28 TclNRRunCallbacks + 80 (tclBasic.c:4656) [inlined] 9 Tcl 0x10102dc28 Tcl_EvalObjv + 116 (tclBasic.c:4394) [inlined] 10 Tcl 0x10102dc28 TclEvalEx + 2216 (tclBasic.c:5495) 11 Tcl 0x1010cdbdc Tcl_Init + 128 (tclInterp.c:400) 12 DLight 0x1009b6eb8 Tk_AppInit + 48 13 DLight 0x1009b83a0 main + 288 best regards, nicolas
248af5b902Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-16 11:36:09c6b85e5ee6Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-16 11:34:253c1945bf8fBug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-15 07:42:43
I think there is enough information here to know where the crash is. It is due to this assertion failing in TclZipfs_TclLibrary() (tclZipfs.c near line 4380):
assert(zipfs_tcl_library_init);
This code was worked on very recently in [0081f10f13].
Nicolas, as I already told you in the other ticket you filed, I don't think it is a good idea to override CFLAGS on the command line as you are doing. Having said that, the assertion failure is probably not related to that. More likely, I have not accounted properly for zipfs being broken on macOS. Not sure why the failure would not show up on github actions though. Will take a look.
Nicolas, can you post the exact fossil commit you are building? A similar report was fixed earlier and want to make sure you are not running a later commit after the fix.
The assertion that is failing is checking that the zipfs init is done (irrespective of whether a zipfs archive is found or not found). On reviewing the code, I cannot see a path where that might happen.
Furthermore, I don't quite understand the initial part of the stack trace in your post.
main->Tk_AppInit->Tcl_Init->TclEvalEx.
On Unix (I do not have a mac), I expect it to look like
main->Tk_MainEx->Tcl_AppInit->Tk_Init->Initialize->TclEvalEx
Even more puzzling, I do not find the symbol Tk_AppInit anywhere in the Tk sources. Are you running some custom application? What is the DLight module showing up in the trace?
Hi Ashok, Christopher, thank you for taking care of this. DLight is the name of my app which is a GUI app that use both Tcl and Tk. one of the user of the app have reported that he could make the app to crash on macOS26 (TK is crashing) so I would like to report to Tk devs where it crash exactly. When I want to post ticket to Tk about a crash I use to compile Tcl and Tk in 'develop' fashion (in order to have line where the crash occurs). I've followed your advice about not to override CFLAGS, so I've compiled bot Tcl and Tk with: make -j 4 -C macosx develop CFLAGS_OPTIMIZE="-fno-omit-frame-pointer -Og -g" $SUDO make -C macosx install-develop and result is the same, when I start my app I got this crash: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x18bac2388 __pthread_kill + 8 1 libsystem_pthread.dylib 0x18bafb88c pthread_kill + 296 2 libsystem_c.dylib 0x18ba04a3c abort + 124 3 libsystem_c.dylib 0x18ba03c70 __assert_rtn + 284 4 Tcl 0x10529b700 <deduplicated_symbol> + 40 5 Tcl 0x105262da0 TclZipfs_TclLibrary + 4 (tclZipfs.c:4380) [inlined] 6 Tcl 0x105262da0 ZipFSTclLibraryObjCmd + 144 (tclZipfs.c:4413) 7 Tcl 0x105147d38 Dispatch + 104 (tclBasic.c:4642) 8 Tcl 0x105144270 TclNRRunCallbacks + 68 (tclBasic.c:4658) [inlined] 9 Tcl 0x105144270 Tcl_EvalObjv + 316 (tclBasic.c:4396) 10 Tcl 0x1051456b8 TclEvalEx + 2896 (tclBasic.c:5497) 11 Tcl 0x1051efc2c Tcl_Init + 128 (tclInterp.c:400) 12 DLight 0x1049e532c Tk_AppInit + 48 13 DLight 0x1049e6814 main + 288 on macOS I believe it's tcl/macosx/GNUmakefile which is responsible of the 'develop' style make ++ nicolas
I am guessing your application main program does not call TclZipfs_AppInit at initialization time causing the assertion to fail. I had added that assertion to ensure that function was always called to check for embedded zip archives before any attempts to load Tcl libraries from zip archives. Reviewing the manpages and TIP's it appears although tclsh and wish always do this, there is no requirement documented that other applications that use their own main programs call that function. So I'll remove the assertion.
Of course, it means embedded ZIPs will not work if TclZipfs_AppInit is not called and the application must use the "traditional" file system located libraries (which is anyways the case on macOS).
Thanks for the report but I do wish you had stated up front this was a custom application and not a stock tclsh or wish build. It would have saved me considerable time reviewing code paths searching for the case where the zipfs-based Tcl library was not initialized.
I have committed a fix for you to try in branch bug-f0b80a3db9
Hi Ashok, thank you for your answer and sorry for the waste of time. in my code at the very start, before Tk_Main(argc, argv, Tk_AppInit); I do call TclZipfs_AppHook(&argc, &argv); but I only do that for Windows as on macOS, there's no zip added at the end of Tcl. I didn't realize that now it could be mandatory on macOS too !! because with TclZipfs_AppHook(&argc, &argv); call also fo macOS, there's no crash anymore. so once again I should have do this before writing this ticket... but it's hard to find that this call was now mandatory. best regards, nicolas
Closing as I have removed the assertion for the reasons stated in the commit message. You debug build on macOS should now work (modulo other issues) irrespective of whether you call TclZipfs_AppInit or not.
@sl1200mk2, not your fault for not calling TclZipfs_AppHook. Nothing in the docs say it is mandatory so I assume it isn't. That is why I removed the assertion that checks that it's been called.