Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #38978] [PATCH] Fix unitialized register error in t/pmc/file.t

4 views
Skip to first unread message

Andy Dougherty

unread,
Apr 25, 2006, 11:34:50 AM4/25/06
to bugs-bi...@rt.perl.org
# New Ticket Created by Andy Dougherty
# Please include the string: [perl #38978]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38978 >


The following patch fixes what I presume is a typo in t/pmc/file.t.
Previously, I expect the only reason it was passing for some folks is that
unused I registers are somehow automatically set to 0 on Linux/x86.

--- parrot-current/t/pmc/file.t Sat Feb 25 00:32:34 2006
+++ parrot-andy/t/pmc/file.t Tue Apr 25 11:29:22 2006
@@ -84,7 +84,7 @@

$S1 = "xpto"
$I1 = $P1."is_file"($S1)
- $I1 = !I1
+ $I1 = !$I1

if $I1 goto ok1
print "not "


--
Andy Dougherty doug...@lafayette.edu

Chromatic

unread,
Apr 25, 2006, 12:06:01 PM4/25/06
to perl6-i...@perl.org, Andy Dougherty, bugs-bi...@rt.perl.org
On Tuesday 25 April 2006 08:34, Andy Dougherty wrote:

> The following patch fixes what I presume is a typo in t/pmc/file.t.
> Previously, I expect the only reason it was passing for some folks is that
> unused I registers are somehow automatically set to 0 on Linux/x86.

I'm not entirely sure that's true (but I don't have my test case to prove it),
but everything passes with this on Linux/PPC and it looks right.

Thanks, applied as #16031.

-- c

Leopold Toetsch

unread,
Apr 25, 2006, 7:39:35 PM4/25/06
to perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com

On Apr 25, 2006, at 17:34, Andy Dougherty (via RT) wrote:

> Previously, I expect the only reason it was passing for some folks is
> that
> unused I registers are somehow automatically set to 0 on Linux/x86.

Unitialized I and N regs have more or less garbage. See also:
$ ./parrot --help-debug
$ ./parrot -D40 ...

Andy Dougherty

unread,
Apr 26, 2006, 10:21:26 AM4/26/06
to Perl6 Internals
On Tue, 25 Apr 2006, Leopold Toetsch via RT wrote:

> On Apr 25, 2006, at 17:34, Andy Dougherty (via RT) wrote:
>
> > Previously, I expect the only reason it was passing for some folks is
> > that
> > unused I registers are somehow automatically set to 0 on Linux/x86.

> Unitialized I and N regs have more or less garbage.

Sort of. It turns out they are automatically set to 0 only for a
debugging build. For a non-debugging build, they also sometimes end up
being zero, but not always. This is likely architecture and compiler
dependent. In the past, this has masked at least three problems in the
test suite where uninitialized registers were inadvertantly used.

> See also:
> $ ./parrot --help-debug
> $ ./parrot -D40 ...

Unfortunately, that doesn't necessarily do anything. The problem is
that -D40 (unlike many of the other -D flags) is only effective if you
are running a debugging build, which I'm not.

$ cat try1.pir
.sub main :main
print "I1 = "
print I1
print "\n"
.end
$ ./parrot try1.pir
I1 = 0
$ ./parrot -D40 try1.pir
I1 = 0

Here's an example that does generate something in a non-initialized
register. It turns out to be rather sensitive to the details of the
file. Small changes make the value of '4437328' turn to either '37'
or '0'.

$ cat try2.pir
.sub main :main
$P1 = new .File
$S1 = "src"


$I1 = $P1."is_file"($S1)

print "$S1 = "
print $S1
print "\n"
print "$I1 = "
print $I1
print "\n"
print "I1 = "
print I1
print "\n"
ok1:
print "ok 1\n"
ok2:
print "ok 2\n"
end
.end


$ ./parrot try2.pir
$S1 = src
$I1 = 0
I1 = 4437328
ok 1
ok 2

--
Andy Dougherty doug...@lafayette.edu

0 new messages