From f2604ef5126b664f988b5866c639fcfcc18f778c Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 1 May 2015 04:30:26 +0000 Subject: dln.c: check incompatible libruby * dln.c (dln_load): check if a different libruby is loaded by the extension library, and then bail out to get rid of very frequent reported stale bug reports. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dln.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'dln.c') diff --git a/dln.c b/dln.c index aa1e622641..b0ac56e55e 100644 --- a/dln.c +++ b/dln.c @@ -1324,6 +1324,21 @@ dln_load(const char *file) error = dln_strerror(); goto failed; } +# if defined RUBY_EXPORT + { + static const char incompatible[] = "incompatible library version"; + void *ex = dlsym(handle, EXPORT_PREFIX"ruby_xmalloc"); + if (ex && ex != ruby_xmalloc) { + +# if !defined __APPLE__ + /* dlclose() segfaults */ + dlclose(handle); +# endif + error = incompatible; + goto failed; + } + } +# endif init_fct = (void(*)())(VALUE)dlsym(handle, buf); if (init_fct == NULL) { -- cgit v1.2.1