From 4aa9e1ace0c240a99bd41b59a3df736948198480 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 20 Jul 2011 15:20:14 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/dl/test_handle.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/dl') diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb index 3f423925d9..cc4df49c84 100644 --- a/test/dl/test_handle.rb +++ b/test/dl/test_handle.rb @@ -169,5 +169,16 @@ module DL 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 -- cgit v1.2.3