ruby-changes:20542
From: naruse <ko1@a...>
Date: Thu, 21 Jul 2011 00:20:24 +0900 (JST)
Subject: [ruby-changes:20542] naruse:r32590 (trunk): Add test for r32586.
naruse 2011-07-21 00:20:14 +0900 (Thu, 21 Jul 2011) New Revision: 32590 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32590 Log: Add test for r32586. FreeBSD (at least 7.2 to 7.2) calls nsdispatch(3) when it calls getaddrinfo(3). And nsdispatch(3) doesn't call dlerror(3) even if it calls _nss_cache_cycle_prevention_function with dlsym(3). So our DL::Handle#sym must call dlerror(3) before call dlsym. In general uses of dlerror(3) should call it before use it. Modified files: trunk/test/dl/test_handle.rb Index: test/dl/test_handle.rb =================================================================== --- test/dl/test_handle.rb (revision 32589) +++ test/dl/test_handle.rb (revision 32590) @@ -169,5 +169,16 @@ handle = DL::Handle::DEFAULT assert_not_nil handle['malloc'] end unless /mswin|mingw/ =~ RUBY_PLATFORM + + def test_dlerror + # FreeBSD (at least 7.2 to 7.2) calls nsdispatch(3) when it calls + # getaddrinfo(3). And nsdispatch(3) doesn't call dlerror(3) even if + # it calls _nss_cache_cycle_prevention_function with dlsym(3). + # So our DL::Handle#sym must call dlerror(3) before call dlsym. + # In general uses of dlerror(3) should call it before use it. + require 'socket' + Socket.gethostbyname("localhost") + DL.dlopen("/usr/lib/libc.so").sym('strcpy') + end if /freebsd/=~ RUBY_PLATFORM end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/