Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 128955
Status: open
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: khw [...] cpan.org
Cc: CAC [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Parameter size mismatch causes segfaults
In working on fixing a core perl5 bug affecting Tk, I had to make several changes to get Tk to work on a 64 bit system. These stemmed from the fact that size_t is 8 bytes on this system, and int is 4. Most of these were involved in calling Tcl_GetStringFromObj(). The length parameter really should be a size_t or ssize_t, and in a few places it is. But the function declares it to be an int, and various callers attempt to cast their size_t* variables to int*. THIS DOES NOT WORK. It may compile, but the value returned will be garbage. Most places have the parameter declared to be an int, and this appears to work. But that int may overflow on 64 bit systems, so they all should be converted to size_t or ssize_t. Because I was only interested in cobbling together something that I could use temporarily, I converted everything to int's, which was enough to get me by. I am attaching my changes to this ticket. Another place where there was a pointer parameter length mismatch is in the call to SvPV at line 630 in objGlue.c Compiling this with a recent gcc version raised many more warnings, some of which looked really serious.
Subject: objGlue.o
Download objGlue.o
application/x-object 1.4m

Message body not shown because it is not plain text.

Subject: tkCanvText.c

Message body is not shown because it is too large.

Subject: tkFrame.c

Message body is not shown because it is too large.

I have opened a pull request on GitHub with these changes in an attempt to help them get merged sooner: https://github.com/eserte/perl-tk/pull/48

I believe there might still be several more instances of this issue, just from looking for occurrences of size_t length or (int *) &length.

Show quoted text
> The length parameter really should be a size_t or ssize_t … But the function declares it to be an int

I agree that would be ideal, but it's probably stuck with being int, since Perl/Tk extensions depend on that definition, and even upstream Tcl/Tk still uses int.


> even upstream Tcl/Tk still uses int.

Actually, it looks like Tcl/Tk 8.7 and 9 are making efforts to use size_t instead.