diff --git a/ChangeLog b/ChangeLog index 9cefa5d11f..a470d687f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu May 14 00:39:29 2015 Nobuyoshi Nakada + + * 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. + Thu May 14 00:29:44 2015 Nobuyoshi Nakada * lib/fileutils.rb (FileUtils#mv): show the exact target path in diff --git a/dln.c b/dln.c index 355cec1090..e5269ca441 100644 --- a/dln.c +++ b/dln.c @@ -106,13 +106,12 @@ dln_loaderror(const char *format, ...) # define USE_DLN_DLOPEN #endif -#ifndef FUNCNAME_PATTERN -# if defined(__hp9000s300) || ((defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && !defined(__ELF__)) || defined(__BORLANDC__) || defined(NeXT) || defined(__WATCOMC__) || defined(MACOSX_DYLD) -# define FUNCNAME_PREFIX "_Init_" -# else -# define FUNCNAME_PREFIX "Init_" -# endif +#if defined(__hp9000s300) || ((defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && !defined(__ELF__)) || defined(__BORLANDC__) || defined(NeXT) || defined(__WATCOMC__) || defined(MACOSX_DYLD) +# define EXTERNAL_PREFIX "_" +#else +# define EXTERNAL_PREFIX "" #endif +#define FUNCNAME_PREFIX EXTERNAL_PREFIX"Init_" #if defined __CYGWIN__ || defined DOSISH #define isdirsep(x) ((x) == '/' || (x) == '\\') @@ -1330,6 +1329,23 @@ 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, EXTERNAL_PREFIX"ruby_xmalloc"); + if (ex && ex != ruby_xmalloc) { + +# if defined __APPLE__ + /* dlclose() segfaults */ + rb_fatal("%s - %s", incompatible, file); +# else + dlclose(handle); + error = incompatible; + goto failed; +# endif + } + } +# endif init_fct = (void(*)())(VALUE)dlsym(handle, buf); if (init_fct == NULL) { diff --git a/version.h b/version.h index d9b49e8d5a..208d5ca9d9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.3" #define RUBY_RELEASE_DATE "2015-05-14" -#define RUBY_PATCHLEVEL 99 +#define RUBY_PATCHLEVEL 100 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 5