nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

static unicode strings re-usage problem with same ord #245

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
sub foo {
    my ( $a, $b ) = @_;
    print "a: ".ord($a)." ; b: ".ord($b)." [ from foo ]\n";
}

print 'a: '. ord(lc("\x{1E9E}"))." ; ";
print "b: ".ord("\x{df}")."\n";
foo(lc("\x{1E9E}"), "\x{df}");
__END__

What is the expected output? 

> perl script.pl
a: 223 ; b: 223
a: 223 ; b: 223 [ from foo ]

What do you see instead?
only failing with -O3

> for l in $(seq 0 3); do echo "# perlcc -O$l"; rm -f script; perlcc -O$l 
script.pl && ./script; done
# perlcc -O0
a: 223 ; b: 223
a: 223 ; b: 223 [ from foo ]
# perlcc -O1
a: 223 ; b: 223
a: 223 ; b: 223 [ from foo ]
# perlcc -O2
a: 223 ; b: 223
a: 223 ; b: 223 [ from foo ]
# perlcc -O3
a: 223 ; b: 223
a: 223 ; b: 195 [ from foo ]

Please use labels and text to provide additional information.

Original issue reported on code.google.com by nicolas....@gmail.com on 2 Dec 2013 at 7:10

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 8 Dec 2013 at 10:25

GoogleCodeExporter commented 9 years ago
This only fails with non-threaded perls >5.10. testcase t/issue245 improved and 
updated.

Original comment by reini.urban on 13 Jan 2014 at 5:44

GoogleCodeExporter commented 9 years ago
That's an internal static string problem.
The pv symbol is being reused.

    Saving pv pv4 "\303\237" cur=2, len=0, static=1 svop const
    constpv turn off SVf_FAKE  "\303\237" svop const
    Saving pv pv4 "\337" cur=1, len=0, static=1 svop const
    constpv turn off SVf_FAKE  "\337" svop const

with a seperate pv4 for "\337" it works okay.

Original comment by reini.urban on 13 Jan 2014 at 6:02

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 13 Jan 2014 at 6:03

GoogleCodeExporter commented 9 years ago
Fixed with commit fdd3375b2bcb5b56277b882aa7a279338c78f5e7
Author: Reini Urban <rurban@cpanel.net>
Date:   Mon Jan 13 12:14:55 2014 -0600

    C: fix #245, hash strtable to cstring, so equal unicode characters are not collapsed

    This fixes t/issue245.t
    Also simplify savepv a bit.

Original comment by reini.urban on 13 Jan 2014 at 6:15