Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-27
15:19
Merge [b95cc2b450d1f6dd]: Fix for [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer. check-in: 5ab7200d3a user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
15:07
Merge [c521a5fc71c623c4]: Possible fix for [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer. check-in: 30dcb931bc user: pooryorick tags: mistake, INCOMPATIBLE_LICENSE
2024-04-25
19:07 • Closed ticket [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer plus 7 oth... artifact: b6e6a88a62 user: jan.nijtmans
17:21 • Ticket [ef23a85ac6]: 3 changes artifact: 99e16dda91 user: gustafn3
15:10 • Ticket [ef23a85ac6]: 3 changes artifact: 9316f64fde user: jan.nijtmans
15:03
Fix for [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer. check-in: b95cc2b450 user: jan.nijtmans tags: trunk, main
14:59
Fix for [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer. check-in: 0753949a8d user: jan.nijtmans tags: core-8-branch
2024-04-24
09:03 • Ticket [ef23a85ac6] Tcl_PanicProc - Tcl9 & NaviServer status still Open ... artifact: 9d3f9dc65e user: gustafn3
2024-04-23
20:24 • Ticket [ef23a85ac6]: 3 changes artifact: b6640ff60a user: jan.nijtmans
20:11
Possible fix for [ef23a85ac6]: Tcl_PanicProc - Tcl9 & NaviServer check-in: c521a5fc71 user: jan.nijtmans tags: bug-ef23a85ac6
00:51 • Ticket [ef23a85ac6] Tcl_PanicProc - Tcl9 & NaviServer status still Open ... artifact: 70243e3a36 user: mookie
2024-04-22
23:57 • Ticket [ef23a85ac6]: 3 changes artifact: 33515be211 user: mookie
23:57 • Ticket [ef23a85ac6]: 3 changes artifact: f9e67f85fe user: mookie
23:55 • Ticket [ef23a85ac6]: 3 changes artifact: cb5086c98a user: mookie
23:54 • Ticket [ef23a85ac6]: 3 changes artifact: c9ad94563a user: mookie
23:51 • Ticket [ef23a85ac6]: 3 changes artifact: 908ff0dabf user: mookie
23:49 • Ticket [ef23a85ac6]: 3 changes artifact: 62a89ea0a2 user: mookie
23:45 • New ticket [ef23a85ac6]. artifact: f236c18c82 user: mookie

Tcl_PanicProc - Tcl9 & NaviServer

Closed / Fixedef23a85ac6bab7d4f2cdb1eb1a03d23bb2e5b289Created 3 years agoUpdated 3 years ago
Descriptionplain2024-04-22 23:45:54
Hi Core,

In attempt of using NaviServer with TCL9.0x -- a module for the server fails, log.c when compiling against TCL9.

OS: FreeBSD 14
TCL: 9.0b1/b2
NaviServer: 4.99 (pre-fix)

After reaching out to Gustaf, dev of NaviServer, a hot-patch has been created.

His explanation:

The issue is that Tcl_PanicProc is defined in Tcl9 with the attribute declaration TCL_NORETURN1, but it seems, this attribute definition has to be provided as well for the prototype. It would be certainly better, if this attribute definition would be part of the type declaration of Tcl_PanicProc in Tcl9. Not very long ago, the same code worked fine, so something has changed in Tcl9.

The patch below addresses this issue, but this is not nice. Maybe, the tcl-core people have a suggestion, since this will effect as well other applications requiring the use of Tcl_SetPanicProc().

Compilation error:

> log.c:262:22: error: incompatible function pointer types passing 'Tcl_PanicProc' (aka 'void (const char *, ...)') to parameter of type 'void (*)(const char *, ...) __attribute__((noreturn))' [-Wincompatible-function-pointer-types]
     Tcl_SetPanicProc(Panic);
                    ^~~~~
 /usr/local/include/tcl.h:2366:37: note: passing argument to parameter 'panicProc' here
                         TCL_NORETURN1 Tcl_PanicProc *panicProc);

NaviServer Issue: https://sourceforge.net/p/naviserver/mailman/message/58763387/

Source to patched log.c: https://github.com/naviserver-project/naviserver/commit/c96c143ac2c7a88b99f8c32e7d140019fe5e7629

Many Thanks,
David F
Referenced by5
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:49:30
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:51:10
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:54:51
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:55:44
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:57:35
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-22 23:57:49
mookie Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-23 00:51:55
jan.nijtmans Ticket [ef23a85ac6]: 3 changes [History diff]2024-04-23 20:24:02
gustafn3plain2024-04-24 09:03:14
The version in branch bug-ef23a85ac6 fixes the issue.
Putting the declaration into the type is the right thing.
jan.nijtmanswiki2024-04-25 15:10:46

Should be fixed [here]

> The version in branch bug-ef23a85ac6 fixes the issue.

Unfortunately, the earlier fix caused warnings on Linux:

/home/runner/work/tcl/tcl/generic/tcl.h:600:1: warning: ‘noreturn’ attribute ignored [-Wattributes]
  600 | typedef TCL_NORETURN1 void (Tcl_PanicProc) (const char *format, ...);
      | ^~~~~~~
which can be seen in the GITHUB build: https://github.com/tcltk/tcl/actions/runs/8812574046/job/24188518470

The best solution, it turns out, is no longer use the `TCL_NORETURN1` option when setting/getting exitproc/panicproc functions, but let `Tcl_Panic()` handle all of this. If the user provides a `TCL_NORETURN` function as panicproc, that's fine. If the user doesn't do that, but provides a function which returns, then `Tcl_Panic()` will handle the last part of exiting.

This way, I think, solves the NaviServer warning, and it handles everything I can think of.

Thanks for the report!

gustafn3plain2024-04-25 17:21:01
I tested with the new version. Everything is still fine.

Btw, the original issue was a compiler error, not a warning. Maybe, raising and error instead of a warning depends on the used compiler and version. 

I am still wondering why nobody else noted this. Everyone calling Tcl_SetPanicProc() was effected by this issue.
jan.nijtmanswiki2024-04-25 19:07:08

Thanks for confirming that it works! Closing.

Log in (anonymous is fine) to add a comment.