From: Motohiro KOSAKI Date: 2011-11-10T08:10:02+09:00 Subject: [ruby-dev:44848] [ruby-trunk - Bug #5429] 64ビットなFreeBSDのioctlでビット31が1なリクエストの時の不具合 Issue #5429 has been updated by Motohiro KOSAKI. fcntl は全プラットフォーム int のようである。めでたい == Linux int fcntl(int fd, int cmd, ... /* arg */ ); https://www.kernel.org/doc/man-pages/online/pages/man2/fcntl.2.html == FreeBSD int fcntl(int fd, int cmd, ...); http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?fcntl+2 == NetBSD int fcntl(int fd, int cmd, ...); http://www.daemon-systems.org/man/fcntl.2.html == OpenBSD int fcntl(int fd, int cmd, ...); http://nixdoc.net/man-pages/OpenBSD/fcntl.2.html == AIX int fcntl(int descriptor, int command, ...) http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Ffcntl.htm == Solaris int fcntl(int fildes, int cmd, /* arg */ ...); http://download.oracle.com/docs/cd/E19963-01/html/821-1463/fcntl-2.html == HP-UX int fcntl(int fildes, int cmd, ... /* arg */); http://nixdoc.net/man-pages/HP-UX/man2/fcntl.2.html == Tru64 int fcntl( int filedes, int request [, int argument |, struct flock *argument |, advfs_opT argument] ); int dup( int filedes ); int dup2( int old, int new ); http://nixdoc.net/man-pages/Tru64/man2/fcntl.2.html == IRIX int fcntl (int fildes, int cmd, ... /* arg */); http://nixdoc.net/man-pages/irix/man2/fcntl.2.html == Darwin int fcntl(int fildes, int cmd, ...); http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/fcntl.2.html ---------------------------------------- Bug #5429: 64ビットなFreeBSDのioctlでビット31が1なリクエストの時の不具合 http://redmine.ruby-lang.org/issues/5429 Author: Makoto Kishimoto Status: Open Priority: Low Assignee: Category: core Target version: 2.0.0 ruby -v: - 64ビットなFreeBSD 8において、ioctl(2)のプロトタイプ宣言は以下のように なっていて、 int ioctl(int d, unsigned long request, ...); ビット31(32ビットであればMSB)が1なリクエストでも、上位ビットがゼロ拡張 された64ビット値を期待しています。 それに対しrubyのtrunkではIO#ioctlの引数の値の範囲は符号付き32ビットに なっていて、最終的にio.cのnogvl_io_cntlに、intを引数としたioctlの 呼び出しがあり、ビット31が1なリクエストは符号拡張されて、ioctlを呼ぶことに なり、 その結果システムメッセージに、(SNDCTL_DSP_SPEED の例) WARNING pid 82043 (initial thread): ioctl sign-extension ioctl ffffffffc0045002 というようなウォーニングが出ます(一応目的の動作はしている)。 回避する修正は (unsigned) とキャストを入れればいいように思うのですが、 他のプラットフォームでの問題や、IO#ioctlの受け入れるべき引数の値の範囲の 問題などがあるので、とりあえずチケットのみ登録します。 -- http://redmine.ruby-lang.org