[#44586] [Ruby 1.9 - Bug #5423][Open] readlineの入力待機中に端末のウィンドウサイズ変更すると入力内容が乱れる — Takuto Matsuu <matsuu@...>

8 messages 2011/10/08

[#44589] [Ruby 1.9 - Bug #5429][Open] 64ビットなFreeBSDのioctlでビット31が1なリクエストの時の不具合 — Makoto Kishimoto <redmine@...>

21 messages 2011/10/09

[#44604] Ruby 2.0 release plan — "NARUSE, Yui" <naruse@...>

ささださんが既にいくつか 2.0 関連のメールを投げていらっしゃいますが、

75 messages 2011/10/18
[#44607] Re: Ruby 2.0 release plan — Yukihiro Matsumoto <matz@...> 2011/10/18

まつもと ゆきひろです

[#44618] Re: Ruby 2.0 release plan — "NARUSE, Yui" <naruse@...> 2011/10/18

(2011/10/18 16:15), Yukihiro Matsumoto wrote:

[#44619] Re: Ruby 2.0 release plan — Yukihiro Matsumoto <matz@...> 2011/10/18

まつもと ゆきひろです

[#44627] Re: Ruby 2.0 release plan — Urabe Shyouhei <shyouhei@...> 2011/10/19

On 10/18/2011 10:16 PM, Yukihiro Matsumoto wrote:

[#44629] Re: Ruby 2.0 release plan — Yukihiro Matsumoto <matz@...> 2011/10/19

まつもと ゆきひろです

[#44631] Re: Ruby 2.0 release plan — Urabe Shyouhei <shyouhei@...> 2011/10/19

たとえば2.0の次のバージョン番号はどうしますか?

[#44633] Re: Ruby 2.0 release plan — "NARUSE, Yui" <naruse@...> 2011/10/20

2011年10月20日3:31 Urabe Shyouhei <[email protected]>:

[#44612] Re: Ruby 2.0 release plan — Yusuke Endoh <mame@...> 2011/10/18

遠藤です。

[#44707] [ruby-trunk - Feature #5512][Open] Integer#/ の改訂 — tadayoshi funaba <redmine@...>

13 messages 2011/10/30

[#44719] [ruby-trunk - Feature #5520][Open] Numeric#exact?、Numeric#inexact? の追加 — tadayoshi funaba <redmine@...>

13 messages 2011/10/31

[ruby-dev:44657] [Ruby 1.9 - Bug #5469][Open] Bus Error when accessing NAN and INFINITY

From: Naohisa Goto <ngotogenome@...>
Date: 2011-10-21 04:24:50 UTC
List: ruby-dev #44657
Issue #5469 has been reported by Naohisa Goto.

----------------------------------------
Bug #5469: Bus Error when accessing NAN and INFINITY
http://redmine.ruby-lang.org/issues/5469

Author: Naohisa Goto
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: -


現在、INFINITYやNANが処理系で定義されていない場合、numeric.c 内の以下の変数を使います。
 const unsigned char rb_infinity[] = "\x00\x00\x80\x7f";
 const unsigned char rb_nan[] = "\x00\x00\xc0\x7f";
(上記はlittle endianの場合のみピックアップ)
しかし、この記述はワード境界のアラインメントを一切考慮していないため、
処理系とCPUアーキテクチャの組み合わせによっては、Bus Error が出ます。
具体的には、Sparc Solaris 10 上の Fujitsu C Compiler 5.6 で作成すると Bus Error が出ました。

以下のパッチのように共用体にすると大丈夫でした。
ただしバイナリ互換性は保たれなくなる気がします。

同じ記述は 1.9.3 にもありますが、メジャーな環境では起きていないようなので、バックポートする必要はないと思います。

===================================================================
--- include/ruby/missing.h	(revision 33498)
+++ include/ruby/missing.h	(working copy)
@@ -124,20 +124,27 @@
 RUBY_EXTERN double cbrt(double);
 #endif
 
+#if !defined(INFINITY) || !defined(NAN)
+union bytestream4_or_float {
+  unsigned char stream[4]; 
+  float float_value;
+};
+#endif
+
 #ifdef INFINITY
 # define HAVE_INFINITY
 #else
 /** @internal */
-RUBY_EXTERN const unsigned char rb_infinity[];
-# define INFINITY (*(float *)rb_infinity)
+RUBY_EXTERN const union bytestream4_or_float rb_infinity;
+# define INFINITY (rb_infinity.float_value)
 #endif
 
 #ifdef NAN
 # define HAVE_NAN
 #else
 /** @internal */
-RUBY_EXTERN const unsigned char rb_nan[];
-# define NAN (*(float *)rb_nan)
+RUBY_EXTERN const union bytestream4_or_float rb_nan;
+# define NAN (rb_nan.float_value)
 #endif
 
 #ifndef isinf
Index: numeric.c
===================================================================
--- numeric.c	(revision 33498)
+++ numeric.c	(working copy)
@@ -66,16 +66,16 @@
 
 #ifdef HAVE_INFINITY
 #elif !defined(WORDS_BIGENDIAN) /* BYTE_ORDER == LITTLE_ENDIAN */
-const unsigned char rb_infinity[] = "\x00\x00\x80\x7f";
+const union bytestream4_or_float rb_infinity = { 0x00, 0x00, 0x80, 0x7f };
 #else
-const unsigned char rb_infinity[] = "\x7f\x80\x00\x00";
+const union bytestream4_or_float rb_infinity = { 0x7f, 0x80, 0x00, 0x00 };
 #endif
 
 #ifdef HAVE_NAN
 #elif !defined(WORDS_BIGENDIAN) /* BYTE_ORDER == LITTLE_ENDIAN */
-const unsigned char rb_nan[] = "\x00\x00\xc0\x7f";
+const union bytestream4_or_float rb_nan = { 0x00, 0x00, 0xc0, 0x7f };
 #else
-const unsigned char rb_nan[] = "\x7f\xc0\x00\x00";
+const union bytestream4_or_float rb_nan = { 0x7f, 0xc0, 0x00, 0x00 };
 #endif
 
 #ifndef HAVE_ROUND




-- 
http://redmine.ruby-lang.org

In This Thread

Prev Next