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