Tk Source Code

View Ticket
Login
2023-12-01
16:09 Closed ticket [d96974d9]: Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc plus 5 other changes artifact: b3549d42 user: jan.nijtmans
2023-10-25
14:38 Ticket [d96974d9]: 3 changes artifact: 34b18e50 user: chrstphrchvz
14:18 Ticket [d96974d9]: 3 changes artifact: 956d9475 user: chrstphrchvz
13:27 Ticket [d96974d9]: 3 changes artifact: 423a2fb7 user: dgp
2023-10-11
15:13
Fix [d96974d99d]: Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc check-in: 37556331 user: jan.nijtmans tags: core-8-6-branch
13:30 Ticket [d96974d9] Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc status still Open with 4 other changes artifact: 5b3c1a44 user: chrstphrchvz
2023-10-10
11:32 Ticket [d96974d9]: 4 changes artifact: fca98f9e user: jan.nijtmans
11:27
Proposed fix for [d96974d99d], which should work with Tcl 8.6, 8.7 and 9.0 check-in: 12043dec user: jan.nijtmans tags: bug-d96974d99d
10:32 Ticket [d96974d9] Do not pass incompatible function pointers to Tcl_EventuallyFree() status still Open with 3 other changes artifact: f3bb1f98 user: chrstphrchvz
10:04 Add attachment d96974d99d72.diff to ticket [d96974d9] artifact: e6babeb2 user: chrstphrchvz
10:03 New ticket [d96974d9] Do not pass incompatible function pointers to Tcl_EventuallyFree(). artifact: fa1b9942 user: chrstphrchvz

Ticket UUID: d96974d99d72955f0f2f799a49be0b62c22c5b62
Title: Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc
Type: Patch Version: 8.6.13
Submitter: chrstphrchvz Created on: 2023-10-10 10:03:13
Subsystem: 81. Portability Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-12-01 16:09:49
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2023-12-01 16:09:49
Description:

As described in https://core.tcl-lang.org/tcl/info/8ab8a138c915

Aside from the attached patch, which mostly undoes [9279332cf22a] and [4854aa119bd0], there is one more instance to address in tkImage.c, but I would first like to understand why DeleteImage() is not consistently used as a Tcl_FreeProc (via Tcl_EventuallyFree()).

User Comments: chrstphrchvz added on 2023-10-25 14:38:01:

Sorry, those warnings/errors were because I tried building with outdated Tcl 8.7 (from before https://core.tcl-lang.org/tcl/info/56cb488cc3d4).


chrstphrchvz added on 2023-10-25 14:18:39:

Don, I assume you are building with Tcl 8.7. There are warnings for Tk 8.7 + Tcl 8.7 which by default are errors in LLVM.org Clang 16. Examples:

tk87ontcl87/generic/tkBusy.c:140:33: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'Tcl_FreeProc *' (aka 'void (*)(char *)') [-Wincompatible-function-pointer-types]
  140 |     Tcl_EventuallyFree(busyPtr, DestroyBusy);
      |                                 ^~~~~~~~~~~
tk87ontcl87/generic/tkBusy.c:265:30: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'Tcl_FreeProc *' (aka 'void (*)(char *)') [-Wincompatible-function-pointer-types]
  265 |         Tcl_EventuallyFree(busyPtr, DestroyBusy);
      |                                     ^~~~~~~~~~~
tk87ontcl87/generic/tkBusy.c:386:30: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'Tcl_FreeProc *' (aka 'void (*)(char *)') [-Wincompatible-function-pointer-types]
  386 |         Tcl_EventuallyFree(busyPtr, DestroyBusy);
      |                                     ^~~~~~~~~~~
tk87ontcl87/generic/tkBusy.c:921:30: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'Tcl_FreeProc *' (aka 'void (*)(char *)') [-Wincompatible-function-pointer-types]
  921 |         Tcl_EventuallyFree(busyPtr, DestroyBusy);
      |                                     ^~~~~~~~~~~


dgp added on 2023-10-25 13:27:45:
Testing the Tk trunk today I see many compiler warnings that
appear to be about this issue.

chrstphrchvz added on 2023-10-11 13:30:07:

For reference: in the Tcl ticket, the issue of compatibility with both Tcl 8 and 9 had been brought up; and there has since been discussion of shortcomings of the originally proposed fixes like [12043dec2720]—revising ticket name accordingly.

Note that in tkSquare.c and ttkWidget.c, the relevant function only calls ckfree(). In my patch, I assumed it was preferable to remove those functions and use TCL_DYNAMIC instead.


jan.nijtmans added on 2023-10-10 11:32:23:

Hi Christofer.

Your patch will work for Tcl 8.6, but the same approach would not work in Tk 8.7 when compiled with Tcl 9.0. Therefore, what I would like to do now is [12043dec272011fd|this].

This approach means that all functions use a (void *) parameter. When used with Tcl 9.0, the type-cast won't be necessary any more, but - hopelully - this way the -fsanitize=function message will be surpressed as well.

Thanks!


Attachments: