Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2025-09-30
23:21 • New ticket [6fbabfe166] Tkinter: Cannot find a usable init.tcl with recent core-... artifact: 3074efeee7 user: chrstphrchvz
2025-09-16
16:51 • Ticket [f0b80a3db9] macOS : crash when building Tcl in develop mode status s... artifact: 69c431817f user: apnadkarni
11:49 • Closed ticket [f0b80a3db9]. artifact: 925a862e8a user: apnadkarni
11:36
Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call ... check-in: 248af5b902 user: apnadkarni tags: trunk, main
11:34
Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call ... check-in: c6b85e5ee6 user: apnadkarni tags: core-9-0-branch
2025-09-15
07:56 • Ticket [f0b80a3db9] macOS : crash when building Tcl in develop mode status s... artifact: e433e44d50 user: sl1200mk2
07:44 • Ticket [f0b80a3db9]: 3 changes artifact: e39b6e31f3 user: apnadkarni
07:42
Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call ... closed check-in: 3c1945bf8f user: apnadkarni tags: bug-f0b80a3db9
06:54 • Ticket [f0b80a3db9] macOS : crash when building Tcl in develop mode status s... artifact: 48dae08acd user: apnadkarni
2025-09-13
13:47 • Ticket [f0b80a3db9]: 3 changes artifact: 7bd128aa71 user: sl1200mk2
06:00 • Ticket [f0b80a3db9]: 3 changes artifact: 93953787a6 user: apnadkarni
02:37 • Ticket [f0b80a3db9]: 3 changes artifact: 6d2405e9b3 user: apnadkarni
02:31 • Ticket [f0b80a3db9]: 3 changes artifact: effe6695b8 user: apnadkarni
01:38 • Ticket [f0b80a3db9]: 3 changes artifact: d36be3fc08 user: chrstphrchvz
2025-09-11
08:50 • New ticket [f0b80a3db9]. artifact: ef22115051 user: sl1200mk2

macOS : crash when building Tcl in develop mode

Closed / Fixedf0b80a3db9443698e13867cb8e01499f1f661fddCreated 1 year agoUpdated 1 year ago
Descriptionplain2025-09-11 08:50:54
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
Referenced by3
  • 248af5b902Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-16 11:36:09
  • c6b85e5ee6Bug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-16 11:34:25
  • 3c1945bf8fBug [f0b80a3db9] Remove assertion that TclZipfs_AppHook has been called as custom apps may not call it. check-in2025-09-15 07:42:43
chrstphrchvzwiki2025-09-13 01:38:27

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].

apnadkarniplain2025-09-13 02:31:57
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.
apnadkarniplain2025-09-13 02:37:28
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.
apnadkarnimarkdown2025-09-13 06:00:04

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?

sl1200mk2plain2025-09-13 13:47:00
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
apnadkarnimarkdown2025-09-15 06:54:09

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.

apnadkarniplain2025-09-15 07:44:41
I have committed a fix for you to try in branch bug-f0b80a3db9
sl1200mk2plain2025-09-15 07:56:06
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
apnadkarnimarkdown2025-09-16 11:49:15

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.

apnadkarniplain2025-09-16 16:51:49
@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.
Log in (anonymous is fine) to add a comment.