develooper Front page | perl.perl5.porters | Postings from July 2012

[perl #113980] [PATCH] pp_syscall: "I32 retval" truncates the returned value

Thread Next
From:
Father Chrysostomos via RT
Date:
July 25, 2012 23:15
Subject:
[perl #113980] [PATCH] pp_syscall: "I32 retval" truncates the returned value
Message ID:
rt-3.6.HEAD-11172-1343283300-946.113980-15-0@perl.org
On Wed Jul 11 03:57:53 2012, oleg@redhat.com wrote:
> On 07/08, Father Chrysostomos via RT wrote:
> >
> > On Thu Jul 05 02:15:16 2012, oleg@redhat.com wrote:
> > > -------------------------------------------------------------------
> > > #!/usr/bin/perl -w
> > > use strict;
> > >
> > > sub find_vdso()
> > > {
> > > 	open my $maps, '<', '/proc/self/maps' or die;
> > > 	/^(.*?)-.*\[vdso\]$/ and return hex $1 for <$maps>;
> > > }
> > >
> > > my $vdso_addr = find_vdso || die 'not 64-bit linux?';
> > >
> > > my $ret = syscall 25,		# __NR_mremap
> > > 		$vdso_addr,	# old_addr
> > > 		1,		# old_len
> > > 		1,		# new_len
> > > 		0,		# flags
> > > 		0;		# new_addr (unused)
> > >
> > > $ret == $vdso_addr or die "FAILED\n";
> > >
> >
> > Thank you.  I’ll have to adjust this a bit to turn it into a test.  Does
> > $^O give you ‘linux’?
> 
> Yes,
> 
> > There is a possibility that another OS might have a plain file called
> > /proc/self/maps whose contents just happen to match the regular
> > expression, resulting in an invalid syscall, and perhaps a crash.
> >
> > So we should skip early if $^O is not appropriate.
> 
> Yes, yes, sure.
> 
> Bu just in case, please note $^O eq 'linux' is not enough.
> 
> The test-case assumes 64-bit linux and perl should be compiled
> as 64-bit application too. Otherwise syscall(25) means stime()
> and should be skipped.

This line accounts for that, does it not?

    my $vdso_addr = find_vdso || die 'not 64-bit linux?';

Please try out the attached patch, based on your script.  If it works
for you, I’ll apply it.

I don’t have access to a 32-bit linux system, so I am unable to test the
skip.  Are you?

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=113980

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About