This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fcntl_ioctl still not 100% sane with unsigned longs
Type: behavior Stage: test needed
Components: Extension Modules Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, gregory.p.smith, loewis, ngie, serhiy.storchaka, trent
Priority: normal Keywords: patch

Created on 2012-10-04 03:46 by ngie, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
python-issue16124.patch ngie, 2012-11-11 12:25 review
python-issue16124.patch ngie, 2012-11-11 12:28 review
python-issue16124.patch ngie, 2012-11-11 12:30 review
Messages (11)
msg171918 - (view) Author: Enji Cooper (ngie) * Date: 2012-10-04 03:46
As discussed in ID # 1471, the type for request is not 100% correct on some platforms (FreeBSD, NetBSD, and OpenBSD, for instance) and the custom platform that I'm using unfortunately uses non-32-bit int ioctls. An autoconf test needs to be added for these platforms and the request parameter needs to be handled properly (I'll take charge of doing that).
msg172112 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-05 18:56
Is it affected for 3.3 and 3.4 also?
msg175348 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 11:36
Yes. Submitting a patch to fix this based on hg master shortly..
msg175354 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 12:24
$ uname -a
FreeBSD bayonetta.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240836M: Sat Sep 22 12:30:11 PDT 2012     gcooper@bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA  amd64
$ ./configure --prefix=/scratch/python-bin/3k/
...
$ make all; make install
...
$ /scratch/python-bin/3k/bin/python3 Lib/test/test_ioctl.py
test_ioctl (__main__.IoctlTests) ... ok
test_ioctl_mutate (__main__.IoctlTests) ... ok
test_ioctl_mutate_1024 (__main__.IoctlTests) ... ok
test_ioctl_mutate_2048 (__main__.IoctlTests) ... ok
test_ioctl_signed_unsigned_code_param (__main__.IoctlTests) ... ok

----------------------------------------------------------------------
Ran 5 tests in 0.003s

OK
msg175355 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 12:25
Sorry; previous patch is not applicable to this issue. This one is.
msg175356 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 12:27
And I missed the int -> unsigned int part. Resubmitting one last time for tonight..
msg175357 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 12:28
Grr... Let's try again.
msg175358 - (view) Author: Enji Cooper (ngie) * Date: 2012-11-11 12:30
... g'night.
msg236030 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-15 09:36
This looks as a duplicate of issue521723 and issue1471. Do you have tests that demonstrate a failure with using ioctl on OpenBSD? May be there are problems on 64-bit big-endian platforms (or even on 64-bit little-endian if additional parameters are passed to ioctl).
msg236031 - (view) Author: Enji Cooper (ngie) * Date: 2015-02-15 09:57
Yes, it's a duplicate. That being said, documentation alone it should be unsigned long for Darwin (OS/X), FreeBSD, OpenBSD. Looking at the definition for ioctl(2), the below example would cause a failure.

I need to hunt around for a practical example as I don't have one offhand (it's something that was found a long time ago in a couple of python 2.6 at my current employer because they have ioctl's that go beyond the 32-bit boundary IIRC...)

fuji:~ ngie$ clang -Wall -c test_ioctl.c
fuji:~ ngie$ clang -DBROKEN -Wall -c test_ioctl.c
test_ioctl.c:9:9: warning: incompatible pointer types initializing 'ioctl_t'
      (aka 'int (*)(int, int, ...)') with an expression of type 'int (int,
      unsigned long, ...)' [-Wincompatible-pointer-types]
ioctl_t _ioctl = ioctl;
        ^        ~~~~~
1 warning generated.
fuji:~ ngie$ cat test_ioctl.c 
#include <sys/ioctl.h>

#ifdef BROKEN
typedef int (*ioctl_t)(int, int, ...);
#else
typedef int (*ioctl_t)(int, unsigned long, ...);
#endif

ioctl_t _ioctl = ioctl;
fuji:~ ngie$ uname -a
Darwin fuji.local 13.4.0 Darwin Kernel Version 13.4.0: Wed Dec 17 19:05:52 PST 2014; root:xnu-2422.115.10~1/RELEASE_X86_64 x86_64
msg236032 - (view) Author: Enji Cooper (ngie) * Date: 2015-02-15 10:00
Another note: mixed endianness might have been a factor as previous versions of the product that were shipped used bi-arch x86 (32-bit userland on 64-bit kernel.
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60328
2015-02-15 10:00:39ngiesetmessages: + msg236032
2015-02-15 09:57:46ngiesetmessages: + msg236031
2015-02-15 09:36:30serhiy.storchakasetversions: - Python 2.6, Python 3.1, Python 3.2, Python 3.3
nosy: + serhiy.storchaka, gregory.p.smith, loewis

messages: + msg236030

stage: test needed
2014-05-14 18:11:11skrahsetnosy: - skrah
2012-11-11 15:20:00pitrousetnosy: + trent, skrah
2012-11-11 12:30:13ngiesetfiles: + python-issue16124.patch

messages: + msg175358
2012-11-11 12:28:45ngiesetfiles: + python-issue16124.patch

messages: + msg175357
2012-11-11 12:28:24ngiesetfiles: - python-issue16124.patch
2012-11-11 12:27:47ngiesetfiles: + python-issue16124.patch

messages: + msg175356
2012-11-11 12:25:55ngiesetfiles: - python-issue13500-test.patch
2012-11-11 12:25:38ngiesetfiles: + python-issue16124.patch

messages: + msg175355
2012-11-11 12:24:14ngiesetfiles: + python-issue13500-test.patch
keywords: + patch
messages: + msg175354

versions: + Python 2.6, Python 3.1, Python 3.2, Python 3.5
2012-11-11 11:36:48ngiesetmessages: + msg175348
2012-10-05 18:56:11asvetlovsetnosy: + asvetlov

messages: + msg172112
versions: + Python 3.3, Python 3.4
2012-10-04 03:46:54ngiecreate