# \[ruby-trunk - Bug #10384\] Fiddle::DLError: unknown symbol "Init\_objspace" during Fiddle::TestHandle#

**URL:** <https://www.ruby-forum.com/t/ruby-trunk-bug-10384-fiddle-unknown-symbol-init-objspace-during-fiddle-testhandle/233695>\
**Category:** Development\
**Created:** [January 5, 2015, 4:39am UTC](https://www.ruby-forum.com/t/ruby-trunk-bug-10384-fiddle-unknown-symbol-init-objspace-during-fiddle-testhandle/233695 "2015-01-05T04:39:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [January 5, 2015, 4:39am UTC](https://www.ruby-forum.com/t/ruby-trunk-bug-10384-fiddle-unknown-symbol-init-objspace-during-fiddle-testhandle/233695/1 "2015-01-05T04:39:21Z")

</div>

Issue #10384 has been updated by Hiroshi SHIBATA.

Related to Bug #9928: Fiddle::TestHandle#test\_NEXT fails on AIX due to  
unexported symbols of extension libraries added

* * *

Bug #10384: Fiddle::DLError: unknown symbol “Init\_objspace” during  
Fiddle::TestHandle#test\_NEXT and Fiddle::TestHandle#test\_static\_sym on  
Solaris

> **[Bug #10384: Fiddle::DLError: unknown symbol "Init\_objspace" during...](https://bugs.ruby-lang.org/issues/10384#change-50794)**
>
> Redmine

- Author: Naohisa G.
- Status: Open
- Priority: Normal
- Assignee:
- Category:
- Target version:
- ruby -v: ruby 2.2.0dev (2014-10-14) [sparc64-solaris2.10]
- Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN

* * *

Solarisにて、make test-all中に以下のエラーが発生することが多くなっています。  
（出ないこともたまにあります。）

```auto
  2) Error:
DL::TestHandle#test_static_sym:
DL::DLError: unknown symbol "Init_objspace"
    /XXXXX/test/dl/test_handle.rb:34:in `sym'
    /XXXXX/test/dl/test_handle.rb:34:in `rescue in test_static_sym'
    /XXXXX/test/dl/test_handle.rb:27:in `test_static_sym'

  4) Error:
Fiddle::TestHandle#test_NEXT:
Fiddle::DLError: unknown symbol "Init_objspace"
    /XXXXX/test/fiddle/test_handle.rb:171:in `[]'
    /XXXXX/test/fiddle/test_handle.rb:171:in `rescue in test_NEXT'
    /XXXXX/test/fiddle/test_handle.rb:144:in `test_NEXT'

  5) Error:
Fiddle::TestHandle#test_static_sym:
Fiddle::DLError: unknown symbol "Init_objspace"
    /XXXXX/test/fiddle/test_handle.rb:41:in `sym'
    /XXXXX/test/fiddle/test_handle.rb:41:in `rescue in test_static_sym'
    /XXXXX/test/fiddle/test_handle.rb:34:in `test_static_sym'

```

Fiddle::Handle.sym および Fiddle::Handle.[] （DL::Handle.sym なども同様）は内部で  
RTLD\_NEXT を使用しています。  
Solarisのman dlsym(3C) より引用します。

> **[Synopsis - man pages section 3: Basic Library Functions](https://docs.oracle.com/cd/E23823_01/html/816-5168/dlsym-3c.html)**
>
> This section describes the core library functions found in the standard C library (libc), the SunOS/BSD compatibility library (libucb), and the various memory allocation libraries. Readers of this section should be familiar with C programming...

```auto
     RTLD_NEXT Instructs dlsym() to search for the named
                     symbol in the objects that were loaded fol-
                     lowing the object from which the dlsym()
                     call is being made.

```

Solarisのdlsymでは、handleに RTLD\_NEXT  
を指定した場合は、そのコードが読み込まれた後に読み込んだシンボルしか検索しません。  
このため、require “objspace” による objspace.so の読み込みが require “fiddle”  
より前に発生していた場合はエラーになります。

（requireの順番によりエラーが出る・出ないの再現コード）

```auto
 % ruby -e 'require "objspace"; require "fiddle"; p 
Fiddle::Handle.sym("Init_objspace")'
-e:1:in `sym': unknown symbol "Init_objspace" (Fiddle::DLError)
        from -e:1:in `<main>'
 % ruby -e 'require "fiddle"; require "objspace"; p 
Fiddle::Handle.sym("Init_objspace")'
9223372034655938496

```

単純にgrepすると、require “objspace” は以下で行われています。

test/dl/test\_handle.rb: require ‘objspace’  
test/fiddle/test\_closure.rb: require ‘objspace’  
test/fiddle/test\_handle.rb: require ‘objspace’  
test/lib/profile\_test\_all.rb:require ‘objspace’  
test/objspace/test\_objspace.rb:require “objspace”  
test/ruby/test\_file\_exhaustive.rb: require “objspace”

これらのテストの実行順番に依存して（ファイルシステムのディレクトリエントリの順番の偶然などのタイミングによって？）、エラーが出たり出なかったりするようです。
