Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Perl library give warnings on use after perl-5.16+ #5

Open
keiranmraine opened this issue Dec 11, 2013 · 3 comments
Open

Perl library give warnings on use after perl-5.16+ #5

keiranmraine opened this issue Dec 11, 2013 · 3 comments

Comments

@keiranmraine
Copy link

Hi,

There seems to be some issue with the XS bindings. I've found this to be a problem on 5.16 and 5.18, okay on 5.14 but I didn't have access to 5.15 to try that.

% perl-5.16.3 -I blib/lib -e 'use Data::Dumper;use Tabix; warn Dumper(\%INC); my $tbi = Tabix->new(-data => q{some.vcf.gz}); print qq{Generated Tabix object\n};'
Subroutine Tabix::tabix_open redefined at blib/lib/Tabix.pm line 17.
Subroutine Tabix::tabix_close redefined at blib/lib/Tabix.pm line 17.
Subroutine Tabix::tabix_query redefined at blib/lib/Tabix.pm line 17.
Subroutine Tabix::tabix_read redefined at blib/lib/Tabix.pm line 17.
Subroutine Tabix::tabix_getnames redefined at blib/lib/Tabix.pm line 17.
Subroutine TabixIterator::tabix_iter_free redefined at blib/lib/Tabix.pm line 17.
$VAR1 = {
          ...
          'Tabix.pm' => 'blib/lib/Tabix.pm',
          'TabixIterator.pm' => 'blib/lib/TabixIterator.pm',
          ...
        };
Generated Tabix object

Regards,
Keiran

@bheavner
Copy link

I've bumped into this too, with a fresh build under perl v5.16.3 In my case, it kills a script I'm trying to run:

Subroutine Tabix::tabix_open redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
Subroutine Tabix::tabix_close redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
Subroutine Tabix::tabix_query redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
Subroutine Tabix::tabix_read redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
Subroutine Tabix::tabix_getnames redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
Subroutine TabixIterator::tabix_iter_free redefined at /usr/local/lib64/perl5/Tabix.pm line 17.
/data/test.vcf
/results/test_out.vcf
/usr/bin/perl: symbol lookup error: /usr/local/lib64/perl5/auto/Tabix/Tabix.so: undefined symbol: ti_open

@keiranmraine
Copy link
Author

The following, although not ideal, will silence this. You need to do it before the use line.

BEGIN { $SIG{__WARN__} = sub {warn $_[0] unless( $_[0] =~ m/^Subroutine Tabix.* redefined/)}; };

@andrewyatz
Copy link

I've seen this problem before when you've got the following situation:

### in A.pm
package A;
use 'B';
sub mysubina {
}
1;

### B.pm
package B;
use 'A';
sub mysubinb {
}
1;

Because both packages choose to use vs. require I think Perl gets a little confused during compilation time and tries to import the subroutines twice not knowing which way to resolve the dependency hierarchy.

For this version of the problem I think it's caused partly by the @EXPORT calls in Tabix.pm and the use of XSLoader::load('Tabix', $VERSION). As you know I don't know all that much about XS but that's the only bit which smells a lot like calling use twice. As you've said using a SIG warn handler will hide the error but it's not really getting rid of it. That would require some recoding of the module I believe.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants