[Xapian-tickets] [Xapian] #522: Search::Xapian Perl module should specify RTLD_GLOBAL in dlopen call

Xapian nobody at xapian.org
Thu Dec 9 01:56:58 GMT 2010


#522: Search::Xapian Perl module should specify RTLD_GLOBAL in dlopen call
----------------------------+-----------------------------------------------
 Reporter:  dskoll          |       Owner:  olly    
     Type:  defect          |      Status:  assigned
 Priority:  normal          |   Milestone:  1.2.4   
Component:  Search::Xapian  |     Version:          
 Severity:  normal          |    Keywords:          
Blockedby:                  |    Platform:  All     
 Blocking:                  |  
----------------------------+-----------------------------------------------
Changes (by olly):

  * status:  new => assigned
  * component:  Other => Search::Xapian
  * milestone:  => 1.2.4


Old description:

> If you're using Search::Xapian as well as other C++ code that links
> against libxapian.so, C++ exceptions mysteriously fail because the weak
> symbols in each .so don't match, so the C++ runtime cannot identify the
> types of the exceptions.
>
> A simple one-line patch to Xapian.pm fixes the problem:
>
> diff --git a/Xapian.pm b/Xapian.pm
> index 643edc1..d071721 100644
> --- a/Xapian.pm
> +++ b/Xapian.pm
> @@ -38,6 +38,11 @@ require DynaLoader;
>
>  our @ISA = qw(DynaLoader);
>
> +# We need to use the RTLD_GLOBAL flag to dlopen() so that other C++
> +# modules that link against libxapian.so get the *same* value for all
> the
> +# weak symbols (eg, the exception classes)
> +sub dl_load_flags { 0x01 }
> +
>  # This allows declaration      use Search::Xapian ':all';
>  # If you do not need this, moving things directly into @EXPORT or
> @EXPORT_OK
>  # will save memory.

New description:

 If you're using Search::Xapian as well as other C++ code that links
 against libxapian.so, C++ exceptions mysteriously fail because the weak
 symbols in each .so don't match, so the C++ runtime cannot identify the
 types of the exceptions.

 A simple one-line patch to Xapian.pm fixes the problem:

 {{{
 diff --git a/Xapian.pm b/Xapian.pm
 index 643edc1..d071721 100644
 --- a/Xapian.pm
 +++ b/Xapian.pm
 @@ -38,6 +38,11 @@ require DynaLoader;

  our @ISA = qw(DynaLoader);

 +# We need to use the RTLD_GLOBAL flag to dlopen() so that other C++
 +# modules that link against libxapian.so get the *same* value for all the
 +# weak symbols (eg, the exception classes)
 +sub dl_load_flags { 0x01 }
 +
  # This allows declaration      use Search::Xapian ':all';
  # If you do not need this, moving things directly into @EXPORT or
 @EXPORT_OK
  # will save memory.
 }}}

--

Comment:

 Thanks for the patch.

 It would be good to make sure this fix works on all platforms, and that it
 continues to work.  How feasible is it to write a regression test?

 I guess we'd need a second Perl module which links to xapian-core and to
 throw an exception and see if we can catch it, or something like that?

-- 
Ticket URL: <http://trac.xapian.org/ticket/522#comment:1>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list