Project

General

Profile

Actions

Bug #1977

closed

test failed in test_isdigit in test/dl/test_func.rb on sparc-solaris-2.10 (64bit)

Added by ngoto (Naohisa Goto) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2009-08-19) [sparc-solaris2.10]
Backport:
[ruby-dev:39152]

Description

=begin
sparc-solaris-2.10 にて64ビットコンパイルした場合、Bug #1967
([ruby-dev:39146])のパッチを適用した後では、以下の2つのdl関連
のテストが失敗(Failure)します。

  1. Failure:
    test_isdigit(DL::TestFunc) [/XXX/test/dl/test_func.rb:21]:
    Failed assertion, no message given.

  2. Failure:
    test_isdigit(DL::TestImport) [/XXX/test/dl/test_import.rb:126]:
    Failed assertion, no message given.

Solaris付属のシステムコール追跡コマンドtrussを使って、
$ truss -t '!all' -u 'libc:isdigit' /XXX/trunk-24578/bin/testrb test/dl -v
のような感じで、isdigit関数の呼び出しを追跡したところ、

(前略)
DL::TestFunc#test_isdigit: /1@1: -> libc:isdigit(0x3100000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
/1@1: -> libc:isdigit(0x3200000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
/1@1: -> libc:isdigit(0x7200000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
0.01 s: F
(中略)
DL::TestImport#test_isdigit: /1@1: -> libc:isdigit(0x3100000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
/1@1: -> libc:isdigit(0x3200000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
/1@1: -> libc:isdigit(0x7200000000, 0xc, 0xffffffffffffffff, 0xfffffffffffffff8)
/1@1: <- libc:isdigit() = 0
0.00 s: F
(後略)

1番目の引数は、本来 0x31, 0x32, 0x72 といった数であるべきところが、
0x3100000000, 0x3200000000, 0x7200000000 になってしまっています。

どうやら、sparc 環境では、引数のint は long に符号拡張されるようです。
(参考文献: http://sdc.sun.co.jp/solaris/tools/private/amd64_migration.html )

標準関数 int putchar(char) にて確認したところ、char も同様に long
に拡張されるので、short もおそらく同様だと思います。
float が double に拡張されるかどうかは確認できていません。
また、sparc上のLinuxなど、Solaris以外ではどうなのかは未確認です。

sparcの場合だけ特別な PACK_MAP と SIZE_MAP を持つようにしたパッチを
以下に添付します。このパッチを当てると dl のテストはすべて成功します。
(注:差分を小さくするためインデントが少々おかしくなっています。)

Index: ext/dl/lib/dl/stack.rb

--- ext/dl/lib/dl/stack.rb (revision 24578)
+++ ext/dl/lib/dl/stack.rb (working copy)
@@ -61,6 +61,36 @@
TYPE_DOUBLE => ALIGN_DOUBLE,
}

  • case RUBY_PLATFORM

  • when /sparc/i

  •  PACK_MAP = {
    
  •    TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"),
    
  •    TYPE_CHAR  => "l!",
    
  •    TYPE_SHORT => "l!",
    
  •    TYPE_INT   => "l!",
    
  •    TYPE_LONG  => "l!",
    
  •    TYPE_FLOAT => "f",
    
  •    TYPE_DOUBLE => "d",
    
  •  }
    
  •  SIZE_MAP = {
    
  •    TYPE_VOIDP => SIZEOF_VOIDP,
    
  •    TYPE_CHAR  => SIZEOF_LONG,
    
  •    TYPE_SHORT => SIZEOF_LONG,
    
  •    TYPE_INT   => SIZEOF_LONG,
    
  •    TYPE_LONG  => SIZEOF_LONG,
    
  •    TYPE_FLOAT => SIZEOF_FLOAT,
    
  •    TYPE_DOUBLE => SIZEOF_DOUBLE,
    
  •  }
    
  •  if defined?(TYPE_LONG_LONG)
    
  •    ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_LONG_LONG
    
  •    PACK_MAP[TYPE_LONG_LONG] = "q"
    
  •    SIZE_MAP[TYPE_LONG_LONG] = SIZEOF_LONG_LONG
    
  •  end
    
  • else

  • PACK_MAP = {
    TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"),
    TYPE_CHAR => "c",
    @@ -86,6 +116,8 @@
    SIZE_MAP[TYPE_LONG_LONG] = SIZEOF_LONG_LONG
    end

  • end

  • def parse_types(types)
    @types = types
    @template = ""
    =end


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #1967: Segmentation fault at test_qsort1 and test_qsort2 in test/dl/test_func.rb running on sparc-solaris-2.10Rejectedtenderlovemaking (Aaron Patterson)08/20/2009Actions
Actions #1

Updated by yugui (Yuki Sonoda) over 14 years ago

  • Category set to ext
  • Target version set to 2.0.0

=begin

=end

Actions #2

Updated by tenderlovemaking (Aaron Patterson) over 14 years ago

  • Assignee set to tenderlovemaking (Aaron Patterson)

=begin

=end

Actions #3

Updated by tenderlovemaking (Aaron Patterson) about 14 years ago

  • Status changed from Open to Closed

=begin
libffi で DL を変換しましたので、もうこの問題はない筈です。しかし、私の手元に sparc-solaris のコンピューターがないので、sparc-solaris でテストは出来ませんでした。
=end

Actions #4

Updated by ngoto (Naohisa Goto) about 14 years ago

=begin
On Wed, 3 Feb 2010 10:51:32 +0900
Aaron Patterson wrote:

libffi で DL を変換しましたので、もうこの問題はない筈です。しかし、私の手元に sparc-solaris のコンピューターがないので、sparc-solaris でテストは出来ませんでした。

libffi-3.0.9.tar.gz をダウンロードし、makeしようとしたのですが、
libffi が gcc 独自拡張の attribute を使っているためか、
Sun Workshop 5.8 (SunStudio 11) の cc ではコンパイルできませんでした。

DLをlibffi依存にしたということは、RubyもGCCを要求することになるのでしょうか?

以下、libffiのmake時のエラーです。
"./include/ffi_common.h", line 103: syntax error before or at: attribute
"./include/ffi_common.h", line 103: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 103: warning: syntax error: empty declaration
"./include/ffi_common.h", line 104: syntax error before or at: attribute
"./include/ffi_common.h", line 104: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 104: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 103
"./include/ffi_common.h", line 104: warning: syntax error: empty declaration
"./include/ffi_common.h", line 105: syntax error before or at: attribute
"./include/ffi_common.h", line 105: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 105: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 104
"./include/ffi_common.h", line 105: warning: syntax error: empty declaration
"./include/ffi_common.h", line 106: syntax error before or at: attribute
"./include/ffi_common.h", line 106: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 106: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 105
"./include/ffi_common.h", line 106: warning: syntax error: empty declaration
"./include/ffi_common.h", line 107: syntax error before or at: attribute
"./include/ffi_common.h", line 107: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 107: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 106
"./include/ffi_common.h", line 107: warning: syntax error: empty declaration
"./include/ffi_common.h", line 108: syntax error before or at: attribute
"./include/ffi_common.h", line 108: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 108: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 107
"./include/ffi_common.h", line 108: warning: syntax error: empty declaration
"./include/ffi_common.h", line 109: syntax error before or at: attribute
"./include/ffi_common.h", line 109: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 109: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 108
"./include/ffi_common.h", line 109: warning: syntax error: empty declaration
"./include/ffi_common.h", line 110: syntax error before or at: attribute
"./include/ffi_common.h", line 110: warning: old-style declaration or incorrect type for: attribute
"./include/ffi_common.h", line 110: identifier redefined: attribute
current : function() returning int
previous: function() returning int : "./include/ffi_common.h", line 109
"./include/ffi_common.h", line 110: warning: syntax error: empty declaration
cc: acomp failed for src/debug.c

--
後藤 直久

=end

Actions #5

Updated by naruse (Yui NARUSE) about 14 years ago

=begin
成瀬です。

2010/2/3 Naohisa GOTO :

On Wed, 3 Feb 2010 10:51:32 +0900
Aaron Patterson wrote:

libffi で DL を変換しましたので、もうこの問題はない筈です。しかし、私の手元に sparc-solaris のコンピューターがないので、sparc-solaris でテストは出来ませんでした。

libffi-3.0.9.tar.gz をダウンロードし、makeしようとしたのですが、
libffi が gcc 独自拡張の attribute を使っているためか、
Sun Workshop 5.8 (SunStudio 11) の cc ではコンパイルできませんでした。

DLをlibffi依存にしたということは、RubyもGCCを要求することになるのでしょうか?

テストありがとうございます。

仰る通り、Sun Studio 11 ではダメなのですが、Sun Studio 12 では libffi をコンパイル可能なようです。
http://sourceware.org/ml/libffi-discuss/2010/msg00016.html
http://jp.sun.com/products/software/tools/studio12/documentation/ss12/whatsnew.html

また、Python 方面によると、頑張れば 11 でも attribute の問題は回避できるようです。
http://inside.ascade.co.jp/node/54

以上で現実問題として解決可能なのかはわたしには判断つきかねますが。。

--
NARUSE, Yui

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0