http://www.perlmonks.org?node_id=1027262


in reply to combination of multiple installed Perls and some environment variables cause segfaults

XS modules compiled for one version of Perl are likely to segfault other Perls. (Though recently p5p have been ensuring binary compatibility across minor versions - i.e. 5.16.0, 5.16.1, 5.16.2 and 5.16.3 should all be binary compatible.)

The problem with PERL5LIB is that environment variables get passed to child processes, so when your Perl 5.14 spawns Perl 5.10, Perl 5.10 sees a lib dir that was intended for 5.14.

You could try adding this near the top of your script:

BEGIN { delete $ENV{PERL5LIB} };

Or you could avoid setting that variable to begin with and instead use lib or use the Perl -I command-line option.

Personally though, I'd suggest App::perlbrew which makes managing multiple versions of Perl a breeze.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
  • Comment on Re: combination of multiple installed Perls and some environment variables cause segfaults
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: combination of multiple installed Perls and some environment variables cause segfaults
by dlamb (Initiate) on Apr 06, 2013 at 22:33 UTC

    Thanks for the reply.

    I don't think I want to delete $ENV{PERL5LIB} because none of these scripts are solely "mine", so I don't want to mess anybody else up.

    My understanding was that use lib or -I were good for individual scripts or one-offs, but not a good solution for permanently setting up a working environment. But I could be wrong.

    Since I already have 2 system perls (legacy 5.8.9 and the aforementioned 5.10.0) and 2 MacPorts perls (5.12 and 5.14), and presumably those MP perls are needed by other programs I have installed so I can't get rid of them, I think adding more Perls with perlbrew would just complicate things.

    Maybe getting netpbm to change to /usr/bin/env perl would be the best solution.

      Adding

      BEGIN { delete $ENV{PERL5LIB} };

      ... to the top if the script shouldn't mess anything up. It will only have any effect on child processes launched by the script - e.g. things launched using system() or backticks.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name