Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 921571 - dev-lang/python-2.7.18_p16-r1[tk] - /.../_tkinter.c: error: passing argument 1 of Tcl_NewUnicodeObj from incompatible pointer type [-Wincompatible-pointer
Summary: dev-lang/python-2.7.18_p16-r1[tk] - /.../_tkinter.c: error: passing argument ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard: patch
Keywords: PATCH
: 942416 945380 (view as bug list)
Depends on:
Blocks: c99-porting gcc-14-stable
  Show dependency tree
 
Reported: 2024-01-07 15:55 UTC by Toralf Förster
Modified: 2025-02-25 07:53 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge-info.txt (emerge-info.txt,21.41 KB, text/plain)
2024-01-07 15:55 UTC, Toralf Förster
Details
dev-lang:python-2.7.18_p16-r1:20240106-221922.log (dev-lang:python-2.7.18_p16-r1:20240106-221922.log,136.96 KB, text/plain)
2024-01-07 15:55 UTC, Toralf Förster
Details
emerge-history.txt (emerge-history.txt,187.76 KB, text/plain)
2024-01-07 15:55 UTC, Toralf Förster
Details
environment (environment,111.79 KB, text/plain)
2024-01-07 15:55 UTC, Toralf Förster
Details
etc.clang.tar.xz (etc.clang.tar.xz,1.12 KB, application/x-xz)
2024-01-07 15:55 UTC, Toralf Förster
Details
etc.portage.tar.xz (etc.portage.tar.xz,32.10 KB, application/x-xz)
2024-01-07 15:55 UTC, Toralf Förster
Details
logs.tar.xz (logs.tar.xz,21.22 KB, application/x-xz)
2024-01-07 15:55 UTC, Toralf Förster
Details
qlist-info.txt.xz (qlist-info.txt.xz,51.85 KB, application/x-xz)
2024-01-07 15:55 UTC, Toralf Förster
Details
temp.tar.xz (temp.tar.xz,36.62 KB, application/x-xz)
2024-01-07 15:55 UTC, Toralf Förster
Details
Patch properly casting python integer pointer to Tcl integer pointer (python-2.7.18-fix-tcl-unichar-cast.patch,1.33 KB, patch)
2025-01-04 09:32 UTC, Anon Emuss
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2024-01-07 15:55:43 UTC
too long lines were shrinked:

building 'ossaudiodev' extension
x86_64-pc-linux-gnu-gcc -fPIC -fno-strict-aliasing -O2 -pipe -march=native -fno-diagnostics-color -fwrapv -DNDEBUG -I. -IInclude -I./Include -I/var/tmp/portage/dev-lang/python-2.7.18_p16-r1/work/Python-2.7.18/Include -I/var/tmp/portage/dev-lang/python-2.7.18_p16-r1/work/Python-2.7.18 -c /var/tmp/por
x86_64-pc-linux-gnu-gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -fno-strict-aliasing -O2 -pipe -march=native -fno-diagnostics-color -fwrapv -DNDEBUG -I. -IInclude -I./Include build/temp.linux-x86_64-2.7/v
building '_tkinter' extension
x86_64-pc-linux-gnu-gcc -fPIC -fno-strict-aliasing -O2 -pipe -march=native -fno-diagnostics-color -fwrapv -DNDEBUG -DWITH_APPINIT=1 -DWITH_BLT=1 -I/usr/X11/include -I. -IInclude -I./Include -I/var/tmp/portage/dev-lang/python-2.7.18_p16-r1/work/Python-2.7.18/Include -I/var/tmp/portage/dev-lang/python
/var/tmp/portage/dev-lang/python-2.7.18_p16-r1/work/Python-2.7.18/Modules/_tkinter.c: In function 'AsObj':
/var/tmp/portage/dev-lang/python-2.7.18_p16-r1/work/Python-2.7.18/Modules/_tkinter.c:1178:38: error: passing argument 1 of 'Tcl_NewUnicodeObj' from incompatible pointer type [-Wincompatible-pointer-types]
 1178 |             return Tcl_NewUnicodeObj(inbuf, size);
      |                                      ^~~~~

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1_desktop-20240104-075517

  -------------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-10
 [2] x86_64-pc-linux-gnu-14 *
clang/llvm (if any):
clang version 17.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/17/bin
Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg
/usr/lib/llvm/17
17.0.6
Python 3.11.7
Available Ruby profiles:
  (none found)
Available Rust versions:
  [1]   rust-bin-1.74.1 *
The following VMs are available for generation-2:
1)	Eclipse Temurin JDK 11.0.20.1_p1 [openjdk-bin-11]
2)	Eclipse Temurin JDK 17.0.8.1_p1 [openjdk-bin-17]
*)	Eclipse Temurin JDK 21.0.1_p12 [openjdk-bin-21]
4)	Eclipse Temurin JDK 8.382_p05 [openjdk-bin-8]
Available Java Virtual Machines:
  [1]   openjdk-bin-8 
  [2]   openjdk-bin-11 
  [3]   openjdk-bin-17 
  [4]   openjdk-bin-21  system-vm

The Glorious Glasgow Haskell Compilation System, version 9.2.8
php cli (if any):
go version go1.21.5 linux/amd64

  HEAD of ::gentoo
commit 14ada442667e801c344a75949f1d9242d7b29c5f
Author: Repository mirror & CI <repomirrorci@gentoo.org>
Date:   Sat Jan 6 22:03:04 2024 +0000

    2024-01-06 22:03:03 UTC

emerge -qpvO dev-lang/python
[ebuild   R   ] dev-lang/python-3.12.1_p1  USE="ensurepip gdbm ncurses pgo readline sqlite ssl tk -bluetooth -build -debug -examples -libedit -test (-valgrind) -verify-sig"
Comment 1 Toralf Förster gentoo-dev 2024-01-07 15:55:44 UTC
Created attachment 881609 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2024-01-07 15:55:46 UTC
Created attachment 881610 [details]
dev-lang:python-2.7.18_p16-r1:20240106-221922.log
Comment 3 Toralf Förster gentoo-dev 2024-01-07 15:55:47 UTC
Created attachment 881611 [details]
emerge-history.txt
Comment 4 Toralf Förster gentoo-dev 2024-01-07 15:55:48 UTC
Created attachment 881612 [details]
environment
Comment 5 Toralf Förster gentoo-dev 2024-01-07 15:55:49 UTC
Created attachment 881613 [details]
etc.clang.tar.xz
Comment 6 Toralf Förster gentoo-dev 2024-01-07 15:55:50 UTC
Created attachment 881614 [details]
etc.portage.tar.xz
Comment 7 Toralf Förster gentoo-dev 2024-01-07 15:55:51 UTC
Created attachment 881615 [details]
logs.tar.xz
Comment 8 Toralf Förster gentoo-dev 2024-01-07 15:55:52 UTC
Created attachment 881616 [details]
qlist-info.txt.xz
Comment 9 Toralf Förster gentoo-dev 2024-01-07 15:55:53 UTC
Created attachment 881617 [details]
temp.tar.xz
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-15 04:12:47 UTC
I think this got fixed by https://github.com/python/cpython/commit/dc191245d8f63f5ab41afff0468b7463a07e7b00.
Comment 11 Ștefan Talpalaru 2024-07-05 14:22:44 UTC
The fix is trivial:

diff '--color=auto' -ur Python-2.7.18.orig/Modules/_tkinter.c Python-2.7.18/Modules/_tkinter.c
--- Python-2.7.18.orig/Modules/_tkinter.c	2020-04-19 23:13:39.000000000 +0200
+++ Python-2.7.18/Modules/_tkinter.c	2024-07-05 16:00:54.630854897 +0200
@@ -1175,7 +1175,7 @@
             return NULL;
         }
         if (sizeof(Py_UNICODE) == sizeof(Tcl_UniChar))
-            return Tcl_NewUnicodeObj(inbuf, size);
+            return Tcl_NewUnicodeObj((const Tcl_UniChar *)inbuf, size);
         allocsize = ((size_t)size) * sizeof(Tcl_UniChar);
         if (allocsize >= size)
             outbuf = (Tcl_UniChar*)attemptckalloc(allocsize);
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-24 06:22:50 UTC
Casting requires rationale.
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-28 18:21:19 UTC
*** Bug 942416 has been marked as a duplicate of this bug. ***
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 09:18:10 UTC
*** Bug 945380 has been marked as a duplicate of this bug. ***
Comment 15 Anon Emuss 2025-01-04 09:32:57 UTC
Created attachment 915817 [details, diff]
Patch properly casting python integer pointer to Tcl integer pointer

I looked it over, and think the cast is correct for x86 (and amd64).  I submitted a patch with the cast (and the other two places I saw where the cast was implicitly being made), and a brief description of why I think it is OK.  Basically, there are two different integer pointers which are the same size on amd64, but different sizes on x86.  The code contains a runtime check that the sizes are the same, and if so, casts the pointers and makes the assignment.  If they are not the same, it allocates memory and copies the values over one at a time.  Technically, I think one of the ``integers'' is a wide char, but that should be treated the same as an integer if the sizes match.

Please let me know if you would prefer I do more research into this.
Comment 16 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2025-01-04 12:03:13 UTC
At this point, I'd rather remove USE=tk entirely.  There's no point in putting any effort to Python 2.7, and the fewer features it has, the fewer vulnerabilities it opens up.
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-04 12:04:08 UTC
(In reply to Anon Emuss from comment #15)
> Created attachment 915817 [details, diff] [details, diff]
> Patch properly casting python integer pointer to Tcl integer pointer
> 
> I looked it over, and think the cast is correct for x86 (and amd64).  I
> submitted a patch with the cast (and the other two places I saw where the
> cast was implicitly being made), and a brief description of why I think it
> is OK.  Basically, there are two different integer pointers which are the
> same size on amd64, but different sizes on x86.  The code contains a runtime
> check that the sizes are the same, and if so, casts the pointers and makes
> the assignment.  If they are not the same, it allocates memory and copies
> the values over one at a time.  Technically, I think one of the ``integers''
> is a wide char, but that should be treated the same as an integer if the
> sizes match.
> 
> Please let me know if you would prefer I do more research into this.

Thanks. The explanation LGTM (and I appreciate you doing that).
Comment 18 Larry the Git Cow gentoo-dev 2025-02-25 07:53:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8e9125cd3a4caae144f8d5d30ebe4884f31011f

commit f8e9125cd3a4caae144f8d5d30ebe4884f31011f
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-02-25 07:51:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-02-25 07:52:28 +0000

    dev-lang/python: drop USE=tk from 2.7
    
    As discussed on IRC. Python 2.7 is on life-support and it needs
    patching to work w/ Modern C.
    
    Closes: https://bugs.gentoo.org/921571
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-lang/python/python-2.7.18_p16-r2.ebuild | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)