Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
B::CC uses same names for lexical variables and temporary values
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Heinz Knutzen  
View profile  
 More options Aug 16 2010, 3:35 pm
From: Heinz Knutzen <heinz.knut...@gmx.de>
Date: Mon, 16 Aug 2010 21:35:55 +0200
Local: Mon, Aug 16 2010 3:35 pm
Subject: B::CC uses same names for lexical variables and temporary values
This is a follow up to my previous test case fail2.pl.

fail3.pl
=====
sub test {
my $tmp5 = 1;
my $x = 2;
if ($x != 3) { 4; }

}

=====

This fails with:
$ cc_harness -o fail3 fail3.c
...
fail3.c: In function ‘pp_sub_test’:
fail3.c:437: error: redeclaration of ‘d_tmp5’ with no linkage
fail3.c:437: note: previous declaration of ‘d_tmp5’ was here

B::CC translates some lexical variables of Perl to lexical variables of C.
The name of the variable is reused from Perl.
But additional variables are generated which hold temporary values with
names like "tmp$i".
The code in "sub load_pad" of B::CC doesn't check for any name clashes.
Hence we get errors with duplicate names like here and in the other test
case "fail2.pl".

--
Heinz Knutzen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Aug 17 2010, 5:29 am
From: Reini Urban <rur...@x-ray.at>
Date: Tue, 17 Aug 2010 11:29:22 +0200
Local: Tues, Aug 17 2010 5:29 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
2010/8/16 Heinz Knutzen <heinz.knut...@gmx.de>:

Thanks for the great analysis.
This seems to be easier to fix than I tought.

As a sidenote:
Do you think it is possible to add googlecode issues for future bugs
by yourself?
I'm not sure if you need a google account for this.

  http://code.google.com/p/perl-compiler/issues/list

I added most of your reports to the issues and started adding them as
new testcase labeled t/issuenn.t so that we see when it is actually
fixed when regressions might appear.
Actually adding issues alone would be enough.
If you have a google account I'll happily add you as "Project
contributor". (to add and resolve issues)

The thing is that adding new general fails to TESTS will make the
testsuite MUCH slower, seperate issues.t are faster to compile and
test then the whole C+CC -O0..4 enchilada.
--
Reini Urban
http://phpwiki.org/           http://murbreak.at/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heinz Knutzen  
View profile  
 More options Aug 17 2010, 7:58 am
From: Heinz Knutzen <heinz.knut...@gmx.de>
Date: Tue, 17 Aug 2010 13:58:52 +0200
Local: Tues, Aug 17 2010 7:58 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
I would propose this patch, which fixes issue 35.

--- /usr/local/lib/perl/5.10.1/B/CC.pm    2010-07-23 23:55:39.000000000
+0200
+++ B/CC.pm    2010-08-17 13:32:08.000000000 +0200
@@ -604,7 +604,7 @@
      my $namesv = $namelist[$ix];
      my $type   = T_UNKNOWN;
      my $flags  = 0;
-    my $name   = "tmp$ix";
+    my $name   = "tmp";
      my $class  = class($namesv);
      if ( !defined($namesv) || $class eq "SPECIAL" ) {
        # temporaries have &PL_sv_undef instead of a PVNV for a name
@@ -628,8 +628,9 @@
          $flags |= REGISTER if $3;
        }
      }
+    $name = "${ix}_$name";
      $pad[$ix] =
-      B::Stackobj::Padsv->new( $type, $flags, $ix, "i_$name", "d_$name" );
+      B::Stackobj::Padsv->new( $type, $flags, $ix, "i$name", "d$name" );

      debug sprintf( "PL_curpad[$ix] = %s\n", $pad[$ix]->peek ) if
$debug{pad};
    }

There seems to be some non-determinism in B::CC.
When applying this patch, the offending variables "x" and "tmp5" aren't
declared any longer in the resulting C code.

I had to change the test programs slightly to get them back.

fail2.pl
=====
sub test {
     { my $x = 1; my $y = $x + 1;}
     my $x = 2;
     if ($x != 3) { 4; }

}

=====

fail3.pl
=====
sub test {
     my $tmp5 = 1;
     my $x = $tmp5 + 1;
     if ($x != 3) { 4; }

}
=====
> As a sidenote:
> Do you think it is possible to add googlecode issues for future bugs
> by yourself?

For joining this mailing list I needed a google account already.
I will add future issues to googlecode myself.
> If you have a google account I'll happily add you as "Project
> contributor". (to add and resolve issues)

What does it mean to resolve issues as contributor?
Will I be able to change the code?
--
Heinz Knutzen

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Aug 17 2010, 8:32 am
From: Reini Urban <rur...@x-ray.at>
Date: Tue, 17 Aug 2010 14:32:48 +0200
Local: Tues, Aug 17 2010 8:32 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
2010/8/17 Heinz Knutzen <heinz.knut...@gmx.de>:

This does not smell right since the new names should
start with i_ or d_ for consistency.

--- lib/B/CC.pm (revision 521)
+++ lib/B/CC.pm (working copy)
@@ -605,7 +605,7 @@
     my $namesv = $namelist[$ix];
     my $type   = T_UNKNOWN;
     my $flags  = 0;
-    my $name   = "tmp$ix";
+    my $name   = "tmp";
     my $class  = class($namesv);
     if ( !defined($namesv) || $class eq "SPECIAL" ) {
       # temporaries have &PL_sv_undef instead of a PVNV for a name
@@ -629,6 +629,7 @@
         $flags |= REGISTER if $3;
       }
     }
+    $name = "$name$ix";
     $pad[$ix] =
       B::Stackobj::Padsv->new( $type, $flags, $ix, "i_$name", "d_$name" );

d_tmp5 sounds better than d5_tmp

> There seems to be some non-determinism in B::CC.
> When applying this patch, the offending variables "x" and "tmp5" aren't
> declared any longer in the resulting C code.

I get d_x2 and d_tmp5 which looks good to me, without the changed test.

Great! Thanks.
I didn't know that you need a google account for joining the mailing
list at all.
This sounds like a blocker for future contributors.

>> If you have a google account I'll happily add you as "Project
>> contributor". (to add and resolve issues)
> What does it mean to resolve issues as contributor?
> Will I be able to change the code?

If you come up with more good patches I'll give you svn write access also.
contributer has issue permissions, not svn I believe.
> --
> Heinz Knutzen

--
Reini Urban

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heinz Knutzen  
View profile  
 More options Aug 17 2010, 9:53 am
From: Heinz Knutzen <heinz.knut...@gmx.de>
Date: Tue, 17 Aug 2010 15:53:25 +0200
Local: Tues, Aug 17 2010 9:53 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
> This does not smell right since the new names should start with i_ or
> d_ for consistency.
>
> d_tmp5 sounds better than d5_tmp

Only adding a number as suffix doesn't solve the problem.
If some name itselfs ends with a number we could get duplicates again.
Example:
x11 -> x111
x -> x2
...
y -> y10
x1 -> x111

Because of this problem I proposed to add the number after the starting "d" or "i".
But if you don't like that we should add it as suffix, but separated with "_":
$name = "$name_$ix";
--
Heinz Knutzen

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heinz Knutzen  
View profile  
 More options Aug 17 2010, 9:56 am
From: Heinz Knutzen <heinz.knut...@gmx.de>
Date: Tue, 17 Aug 2010 15:56:33 +0200
Local: Tues, Aug 17 2010 9:56 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
Am I supposed to add a comment like this to issue 35?
Should it be sent to the mailing list as well?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Aug 17 2010, 10:22 am
From: Reini Urban <rur...@x-ray.at>
Date: Tue, 17 Aug 2010 16:22:56 +0200
Local: Tues, Aug 17 2010 10:22 am
Subject: Re: [perl-compiler] B::CC uses same names for lexical variables and temporary values
2010/8/17 Heinz Knutzen <heinz.knut...@gmx.de>:

> Am I supposed to add a comment like this to issue 35?
> Should it be sent to the mailing list as well?

Into the issue is better.

If it's of general interest to the list.

Hmm, okay then.

>> But if you don't like that we should add it as suffix, but separated with
>> "_":
>> $name = "$name_$ix";

I see.
tmp names are not affected because they have no name, but named lexicals are.
So we'll also have to add  a test case also where have a named pad
with such a nameclash.

What is your google account name btw?
--
Reini


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »