Discussion:
[rt.cpan.org #81375] chdir without cc
Bernhard M. W. via RT
2012-11-23 12:52:46 UTC
Permalink
Fri Nov 23 07:52:45 2012: Request 81375 was acted upon.
Transaction: Ticket created by bmwiedemann
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >


I used Inline C in eval
to make optional acceleration
and fallback to generic perl if unavailable,
but this failed when no gcc was installed,
because Inline would chdir to the _Inline/build/xxx_xxxx dir
and remain there when the program started

This caused errors with modules in "." not being found
and output files going to the wrong place.
Sisyphus via RT
2012-11-24 01:17:09 UTC
Permalink
Fri Nov 23 20:17:08 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
I used Inline C in eval
to make optional acceleration
and fallback to generic perl if unavailable,
but this failed when no gcc was installed,
because Inline would chdir to the _Inline/build/xxx_xxxx dir
and remain there when the program started
This caused errors with modules in "." not being found
and output files going to the wrong place.
Could you post a simple demo script ? I can't reproduce the problem.

I tried the following test script:

########################
use strict;
use warnings;

eval {
require Inline; Inline->import (C => Config =>
BUILD_NOISY => 1);

require Inline; Inline->import (C =><<' EOC');

int foo() {
warn("Using Inline\n");
return 42;
}

EOC
};

# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
if($@) {
*foo =\&bar;
}

sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}

my $x = foo();
print "$x\n";
########################

If I hide cc (gcc.exe in my case), the build fails for that reason, and
the script falls back to the pure perl implementation (sub bar).
This is as it's meant to be, and as it should be.

Cheers,
Rob
Bernhard M. W. via RT
2012-11-24 12:56:39 UTC
Permalink
Sat Nov 24 07:56:37 2012: Request 81375 was acted upon.
Transaction: Correspondence added by bmwiedemann
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Sisyphus via RT
If I hide cc (gcc.exe in my case), the build fails for that reason, and
the script falls back to the pure perl implementation (sub bar).
This is as it's meant to be, and as it should be.
I appended to your script:
system("pwd");

then did
mv /usr/bin/cc{,.bak}
rm -rf _Inline
perl testc.pl
[...]
Starting "make" Stage
/usr/bin/perl /usr/lib/perl5/5.16.0/ExtUtils/xsubpp -typemap
"/usr/lib/perl5/5.16.0/ExtUtils/typemap" testc_pl_b91d.xs >
testc_pl_b91d.xsc && mv testc_pl_b91d.xsc testc_pl_b91d.c
cc -c -I"/home/bernhard/temp" -D_REENTRANT -D_GNU_SOURCE
-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmessage-length=0 -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -g -Wall -pipe -DVERSION=\"0.00\"
-DXS_VERSION=\"0.00\" -fPIC
"-I/usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE" testc_pl_b91d.c
/bin/sh: cc: command not found
make: *** [testc_pl_b91d.o] Error 127
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d

and it showed that it changed the current dir for the perl process
Sisyphus via RT
2012-11-25 00:52:31 UTC
Permalink
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
Yes, this could be fixed from within the script I provided as follows:

#################################
use strict;
use warnings;
use Cwd;


my $cwd = getcwd();

eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);

require Inline; Inline->import (C =><<' EOC');

int foo() {
warn("Using Inline\n");
return 42;
}

EOC
};

# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
if($@) {
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}

sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}

my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################

(I've used Cwd::getcwd instead of the pwd system call because pwd is not
available on all systems.)

However, I think (not yet fully tested) this can also be fixed quite
simply from within C.pm by rewriting sub compile as:

#################################
sub compile {
my $o = shift;

my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;

chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
die if $@;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################

So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.

Thanks for the report !

Cheers,
Rob
dcmertens.perl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org via RT
2012-11-26 23:53:29 UTC
Permalink
Mon Nov 26 18:53:28 2012: Request 81375 was acted upon.
Transaction: Correspondence added by dcmertens.perl-***@public.gmane.org
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >


For the curious, a CPAN solution that handles this *very* nicely is
p3rl.org/File::chdir

David
Post by Sisyphus via RT
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
#################################
use strict;
use warnings;
use Cwd;
my $cwd = getcwd();
eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);
require Inline; Inline->import (C =><<' EOC');
int foo() {
warn("Using Inline\n");
return 42;
}
EOC
};
# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}
sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}
my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################
(I've used Cwd::getcwd instead of the pwd system call because pwd is not
available on all systems.)
However, I think (not yet fully tested) this can also be fixed quite
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.
Thanks for the report !
Cheers,
Rob
Xiao Yafeng
2012-11-27 02:02:28 UTC
Permalink
I vote for David, It's a bug from chdir other than Inline.
Post by dcmertens.perl-***@public.gmane.org via RT
Mon Nov 26 18:53:28 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
For the curious, a CPAN solution that handles this *very* nicely is
p3rl.org/File::chdir
David
Post by Sisyphus via RT
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
#################################
use strict;
use warnings;
use Cwd;
my $cwd = getcwd();
eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);
require Inline; Inline->import (C =><<' EOC');
int foo() {
warn("Using Inline\n");
return 42;
}
EOC
};
# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}
sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}
my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################
(I've used Cwd::getcwd instead of the pwd system call because pwd is not
available on all systems.)
However, I think (not yet fully tested) this can also be fixed quite
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.
Thanks for the report !
Cheers,
Rob
Xiao Yafeng via RT
2012-11-27 02:03:01 UTC
Permalink
Mon Nov 26 21:03:00 2012: Request 81375 was acted upon.
Transaction: Correspondence added by xyf.xiao-***@public.gmane.org
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >


I vote for David, It's a bug from chdir other than Inline.
Post by dcmertens.perl-***@public.gmane.org via RT
Mon Nov 26 18:53:28 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
For the curious, a CPAN solution that handles this *very* nicely is
p3rl.org/File::chdir
David
Post by Sisyphus via RT
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
#################################
use strict;
use warnings;
use Cwd;
my $cwd = getcwd();
eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);
require Inline; Inline->import (C =><<' EOC');
int foo() {
warn("Using Inline\n");
return 42;
}
EOC
};
# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}
sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}
my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################
(I've used Cwd::getcwd instead of the pwd system call because pwd is not
available on all systems.)
However, I think (not yet fully tested) this can also be fixed quite
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.
Thanks for the report !
Cheers,
Rob
David Mertens
2012-11-27 04:13:25 UTC
Permalink
Er, sorry, I wasn't trying to argue that this is an error in Perl or a CPAN
dependency. Rather, my comment was meant for the edification of anybody
following this list of communication. As it is, if Inline doesn't mind
adding a dependency, then perhaps adding the dependency on File::chdir
would make this a little easier. But I don't think that such a dependency
is necessary by any means.

David


On Mon, Nov 26, 2012 at 8:03 PM, Xiao Yafeng via RT
Post by Xiao Yafeng via RT
Mon Nov 26 21:03:00 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
I vote for David, It's a bug from chdir other than Inline.
Post by dcmertens.perl-***@public.gmane.org via RT
Mon Nov 26 18:53:28 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
For the curious, a CPAN solution that handles this *very* nicely is
p3rl.org/File::chdir
David
Post by Sisyphus via RT
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
#################################
use strict;
use warnings;
use Cwd;
my $cwd = getcwd();
eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);
require Inline; Inline->import (C =><<' EOC');
int foo() {
warn("Using Inline\n");
return 42;
}
EOC
};
# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}
sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}
my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################
(I've used Cwd::getcwd instead of the pwd system call because pwd is
not
Post by dcmertens.perl-***@public.gmane.org via RT
Post by Sisyphus via RT
available on all systems.)
However, I think (not yet fully tested) this can also be fixed quite
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.
Thanks for the report !
Cheers,
Rob
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan
dcmertens.perl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org via RT
2012-11-27 04:13:38 UTC
Permalink
Mon Nov 26 23:13:37 2012: Request 81375 was acted upon.
Transaction: Correspondence added by dcmertens.perl-***@public.gmane.org
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >


Er, sorry, I wasn't trying to argue that this is an error in Perl or a CPAN
dependency. Rather, my comment was meant for the edification of anybody
following this list of communication. As it is, if Inline doesn't mind
adding a dependency, then perhaps adding the dependency on File::chdir
would make this a little easier. But I don't think that such a dependency
is necessary by any means.

David


On Mon, Nov 26, 2012 at 8:03 PM, Xiao Yafeng via RT
Post by Xiao Yafeng via RT
Mon Nov 26 21:03:00 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
I vote for David, It's a bug from chdir other than Inline.
Post by dcmertens.perl-***@public.gmane.org via RT
Mon Nov 26 18:53:28 2012: Request 81375 was acted upon.
Queue: Inline
Subject: Re: [rt.cpan.org #81375] chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
For the curious, a CPAN solution that handles this *very* nicely is
p3rl.org/File::chdir
David
Post by Sisyphus via RT
Sat Nov 24 19:52:30 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Bernhard M. W. via RT
system("pwd");
[snip]
Post by Bernhard M. W. via RT
Using Pure Perl Implementation
42
/home/bernhard/temp/_Inline/build/testc_pl_b91d
and it showed that it changed the current dir for the perl process
#################################
use strict;
use warnings;
use Cwd;
my $cwd = getcwd();
eval {
require Inline; Inline->import (C => Config =>
#CC => 'bogus', # Easy way to make the build fail
BUILD_NOISY => 1);
require Inline; Inline->import (C =><<' EOC');
int foo() {
warn("Using Inline\n");
return 42;
}
EOC
};
# If Inline is unavailable, foo() simply calls
# the sub bar() pure perl implementation.
chdir $cwd or warn "Couldn't chdir to $cwd";
*foo =\&bar;
}
sub bar {
warn("Using Pure Perl Implementation\n");
return 42;
}
my $x = foo();
print "$x\n";
print $cwd, "\n";
#################################
(I've used Cwd::getcwd instead of the pwd system call because pwd is
not
Post by dcmertens.perl-***@public.gmane.org via RT
Post by Sisyphus via RT
available on all systems.)
However, I think (not yet fully tested) this can also be fixed quite
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
So I'll go with that changed version of C.pm's sub compile unless, in
the course of more thorough testing, I discover a problem with it.
If it tests ok for me, I'll release an Inline-0.51_03 that contains the
fix in a day or two.
Thanks for the report !
Cheers,
Rob
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan
Sisyphus via RT
2012-11-27 11:37:08 UTC
Permalink
Tue Nov 27 06:37:04 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Xiao Yafeng
I vote for David, It's a bug from chdir other than Inline.
File::chdir certainly provides an elegant solution to the problem, but
I'll stick with using the eval{} safety net, for the moment at least.
I'm not really all that keen to introduce a new dependency just to save
a couple of lines of code.

I do think it's an Inline::C bug.
Admittedly, it's a bit unusual to want to safeguard Inline::C code
against the absence of a C compiler (or of a missing make utility or of
uncompilable code, etc.), but I think one is entitled to do that. And if
one wants to do that by using eval{} (as the OP does), then one has
every right to expect that the script will return to the *original* cwd
if $@ gets set.
I think chdir() is behaving as it should. If we want to claim that it's
not an Inline::C bug, then we would have to argue that the OP is doing
something that's not allowed. (But of course, IMO, he isn't doing
anything wrong.)

Cheers,
Rob
Sisyphus via RT
2012-11-28 11:15:12 UTC
Permalink
Wed Nov 28 06:15:10 2012: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >
Post by Sisyphus via RT
#################################
sub compile {
my $o = shift;
my $build_dir = $o->{API}{build_dir};
my $cwd = &cwd;
($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
chdir $build_dir;
eval {
$o->call('makefile_pl', '"perl Makefile.PL"', 2);
$o->call('make', '"make"', 2);
$o->call('make_install', '"make install"', 2);
};
chdir $cwd;
$o->call('cleanup', 'Cleaning Up', 2);
}
#################################
I've just uploaded Inline-0.51_03 to CPAN.
It contains the (above) modified sub compile, along with an additional
test script (C/t/20eval.t) that's designed to check that it works as
expected.

Feel free to give this change a good prod and a poke ... and let me know
if it's inadequate in any way.

Cheers,
Rob
Sisyphus via RT
2013-03-07 02:13:30 UTC
Permalink
Wed Mar 06 21:13:29 2013: Request 81375 was acted upon.
Transaction: Correspondence added by SISYPHUS
Queue: Inline
Subject: chdir without cc
Broken in: 0.50
Severity: Normal
Owner: Nobody
Requestors: bernhard+cpan-***@public.gmane.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81375 >


Fixed in 0.52.
Thank you for the report.

Loading...