Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

wierd segmentation fault with correct code. #606

Closed p6rt closed 15 years ago

p6rt commented 15 years ago

Migrated from rt.perl.org#62176 (status was 'resolved')

Searchable as RT62176$

p6rt commented 15 years ago

From @finanalyst

Using the idiom in http://www.rakudo.org/2008/12/its-sort-of-like.html causes a segmentation error.

The following gets a hash of skaters with the averages. Next is to sort hash by average, and print top three

#!/usr/local/bin/perl6

# Solution to Advanced Event 2, 2008 scripting games, http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx

use v6; my %aves; my @​list; my $scores = open('./skaters.txt', :r) or die $!;

for =$scores {   @​list = split /\,/,$_;   @​list[1..7].sort;   %aves{@​list[0]} = ([+] @​list[2..6]) / 5; };

.say for %aves; .say for %aves.sort​: {.value};

p6rt commented 15 years ago

From @finanalyst

skaters.pl

p6rt commented 15 years ago

From @finanalyst

Janko Cajhen,84,80,61,81,71,62,76 Ryan Calafato,59,93,93,80,67,73,95 Iulian Calinov,56,70,76,93,79,83,58 Geert Camelbeke,97,61,55,73,70,92,63 David Campbell,87,66,62,73,76,91,91 John III Campbell,93,51,61,55,84,99,91 Chris Cannon,60,79,73,63,51,60,61 Jon Cantrell,59,64,99,66,73,52,65 Jun Cao,64,80,83,65,57,82,97 Anthony Cappiello-Guy,89,74,56,58,51,79,84 Cyril Carbonati,97,57,77,90,78,64,58 Richard Carey,80,78,55,88,54,91,95 Jason Carlson,93,68,79,73,91,88,60 Ty Carlson,60,84,77,73,84,50,65 Fernando Caro,58,97,56,79,74,52,53 Rob Caron,85,54,51,59,99,80,89 Andy Carothers,89,88,93,64,95,51,81 Chase Carpenter,94,93,58,92,94,86,60 Matthew Carroll,75,67,52,85,60,80,57 Adam Carter,62,75,72,55,86,60,60 Carlos Carvallo,87,95,56,84,52,83,79 Rob Cason,97,71,97,57,51,69,83 Gitte Casparij,54,89,99,55,51,62,79 Joao Casqueiro,93,50,75,84,57,52,80 Giorgio Cavaglieri,82,63,61,80,88,78,58 Matt Cavallari,53,54,52,57,66,73,80 Luisa Cazzaniga,96,71,71,87,77,59,50 Andrew Cencini,75,52,83,80,63,51,96 Baris Cetinok,86,77,91,50,84,84,71 Sean Chai,71,64,73,85,62,81,61 Gareth Chan,84,51,87,75,72,66,84 Greg Chapman,81,53,88,78,83,80,91 Mathew Charles,57,58,79,80,89,86,67 Sootha Charncherngkha,96,60,92,98,66,66,56 Neil Charney,87,82,83,81,86,71,64 Mohammad Chami,95,74,99,86,51,54,57 Ankur Chavda,99,53,81,60,96,92,80 Francisco Chaves,99,91,55,68,79,62,61 Hao Chen,99,86,62,84,63,77,59 Jacky Chen,76,62,66,92,80,50,95 John Y. Chen,62,59,82,52,76,82,57 Yao-Qiang Cheng,69,72,87,57,58,67,77 Jeff Chia,72,74,89,56,76,95,89 Lee Theng Chia,79,59,60,60,59,64,99 Martin Chisholm,93,91,79,92,64,80,83 Michal Chmiela,86,78,51,66,89,74,56 Manish Chopra,58,78,55,60,73,84,77 Ray Chow,90,78,64,91,62,61,88 Terri Chudzik,88,54,91,95,69,95,55 Bjarke Rust Christensen,99,91,88,59,81,54,97 Nicholas Christopoulos,93,54,50,64,85,73,83 Ranjit Varkey Chudukatil,55,50,79,80,85,54,59 Guido Chuffart,67,57,88,97,97,96,93 Petra Chvojková,64,71,78,57,70,69,85 Alice Ciccu,88,64,56,80,95,88,72 Ewa Ciesielska,54,57,77,84,89,51,99 Molly Clark,82,95,69,69,69,77,90 Leah Clelland,66,85,65,89,55,81,55 Christian Cletus,84,78,96,80,51,86,96 Mark-Stuart Cochrane,51,98,59,99,63,70,72 Pat Coleman,81,53,99,77,58,90,96 Jean-Charles Colon,64,72,62,93,88,89,87 Craig M. Combel,92,77,57,64,80,55,55 Aaron Con,70,61,63,98,72,99,79 Steve Conn,77,59,99,68,83,74,87 Peter Connelly,97,81,80,68,68,95,82 Cathan Cook,95,71,90,70,94,60,72 Kevin Cook,60,58,52,94,91,62,97 Patrick M. Cook,57,63,59,70,87,54,75 Jeroen Cool,77,86,58,91,68,84,65 Kenneth Cools,71,90,71,60,91,87,87 Jim Corbin,86,91,76,99,55,85,60 Michel Cordani,97,62,65,68,60,85,62 Cecilia Cornejo,65,94,96,85,54,96,87 Eva Corets,99,59,86,85,73,59,86 Ryan Cornelsen,57,69,83,65,82,92,96 Robin Counts,71,59,56,50,68,66,67 Brian Cox,89,62,67,64,75,78,93 Oliver Cox,63,64,97,56,51,80,95 Ovidiu V. Cr?ciun,63,82,50,96,85,83,92 Jack Creasey,92,91,96,81,74,81,84 Armin Cremerius-Günther,96,96,60,64,67,59,83 Ioan Crisiarcu,98,70,54,88,90,59,87 María Jesús Cuesta,92,54,64,85,98,59,96 Grant Culbertson,72,94,92,69,51,68,54 Scott Culp,58,76,51,62,56,74,71 Gonçalo Cunha,93,64,88,80,99,61,77 Conor Cunningham,92,62,50,59,82,56,85 Shiraz Cupala,87,68,88,93,50,91,71 Douglas Curran,80,80,51,56,79,86,93 Pawel Czernek,72,84,84,99,70,72,64 Wojciech Czupta,89,53,96,81,63,65,85

p6rt commented 15 years ago

From @finanalyst

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286

When I run the program below, it runs and I get almost the right answer (but uninitialised values and incorrect output).

But when I comment out the 'say' line and uncomment the line below it, I get a segmentation fault.

#!/usr/local/bin/perl6

# Solution to Advanced Event 2, 2008 scripting games, http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx

use v6; my %players; my $scores = open('./skaters.txt', :r) or die $!; my $name; my @​list;

for =$scores {   ($name,@​list) = .split(/\,/);   @​list .=sort;   %players{$name} = ([+] @​list[2..6]) / 5; };

my @​ranking = %players.sort​: { .value }; for \ -> $m {   given pop @​ranking {   say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_";   }; };

p6rt commented 15 years ago

From @finanalyst

Janko Cajhen,84,80,61,81,71,62,76 Ryan Calafato,59,93,93,80,67,73,95 Iulian Calinov,56,70,76,93,79,83,58 Geert Camelbeke,97,61,55,73,70,92,63 David Campbell,87,66,62,73,76,91,91 John III Campbell,93,51,61,55,84,99,91 Chris Cannon,60,79,73,63,51,60,61 Jon Cantrell,59,64,99,66,73,52,65 Jun Cao,64,80,83,65,57,82,97 Anthony Cappiello-Guy,89,74,56,58,51,79,84 Cyril Carbonati,97,57,77,90,78,64,58 Richard Carey,80,78,55,88,54,91,95 Jason Carlson,93,68,79,73,91,88,60 Ty Carlson,60,84,77,73,84,50,65 Fernando Caro,58,97,56,79,74,52,53 Rob Caron,85,54,51,59,99,80,89 Andy Carothers,89,88,93,64,95,51,81 Chase Carpenter,94,93,58,92,94,86,60 Matthew Carroll,75,67,52,85,60,80,57 Adam Carter,62,75,72,55,86,60,60 Carlos Carvallo,87,95,56,84,52,83,79 Rob Cason,97,71,97,57,51,69,83 Gitte Casparij,54,89,99,55,51,62,79 Joao Casqueiro,93,50,75,84,57,52,80 Giorgio Cavaglieri,82,63,61,80,88,78,58 Matt Cavallari,53,54,52,57,66,73,80 Luisa Cazzaniga,96,71,71,87,77,59,50 Andrew Cencini,75,52,83,80,63,51,96 Baris Cetinok,86,77,91,50,84,84,71 Sean Chai,71,64,73,85,62,81,61 Gareth Chan,84,51,87,75,72,66,84 Greg Chapman,81,53,88,78,83,80,91 Mathew Charles,57,58,79,80,89,86,67 Sootha Charncherngkha,96,60,92,98,66,66,56 Neil Charney,87,82,83,81,86,71,64 Mohammad Chami,95,74,99,86,51,54,57 Ankur Chavda,99,53,81,60,96,92,80 Francisco Chaves,99,91,55,68,79,62,61 Hao Chen,99,86,62,84,63,77,59 Jacky Chen,76,62,66,92,80,50,95 John Y. Chen,62,59,82,52,76,82,57 Yao-Qiang Cheng,69,72,87,57,58,67,77 Jeff Chia,72,74,89,56,76,95,89 Lee Theng Chia,79,59,60,60,59,64,99 Martin Chisholm,93,91,79,92,64,80,83 Michal Chmiela,86,78,51,66,89,74,56 Manish Chopra,58,78,55,60,73,84,77 Ray Chow,90,78,64,91,62,61,88 Terri Chudzik,88,54,91,95,69,95,55 Bjarke Rust Christensen,99,91,88,59,81,54,97 Nicholas Christopoulos,93,54,50,64,85,73,83 Ranjit Varkey Chudukatil,55,50,79,80,85,54,59 Guido Chuffart,67,57,88,97,97,96,93 Petra Chvojková,64,71,78,57,70,69,85 Alice Ciccu,88,64,56,80,95,88,72 Ewa Ciesielska,54,57,77,84,89,51,99 Molly Clark,82,95,69,69,69,77,90 Leah Clelland,66,85,65,89,55,81,55 Christian Cletus,84,78,96,80,51,86,96 Mark-Stuart Cochrane,51,98,59,99,63,70,72 Pat Coleman,81,53,99,77,58,90,96 Jean-Charles Colon,64,72,62,93,88,89,87 Craig M. Combel,92,77,57,64,80,55,55 Aaron Con,70,61,63,98,72,99,79 Steve Conn,77,59,99,68,83,74,87 Peter Connelly,97,81,80,68,68,95,82 Cathan Cook,95,71,90,70,94,60,72 Kevin Cook,60,58,52,94,91,62,97 Patrick M. Cook,57,63,59,70,87,54,75 Jeroen Cool,77,86,58,91,68,84,65 Kenneth Cools,71,90,71,60,91,87,87 Jim Corbin,86,91,76,99,55,85,60 Michel Cordani,97,62,65,68,60,85,62 Cecilia Cornejo,65,94,96,85,54,96,87 Eva Corets,99,59,86,85,73,59,86 Ryan Cornelsen,57,69,83,65,82,92,96 Robin Counts,71,59,56,50,68,66,67 Brian Cox,89,62,67,64,75,78,93 Oliver Cox,63,64,97,56,51,80,95 Ovidiu V. Cr?ciun,63,82,50,96,85,83,92 Jack Creasey,92,91,96,81,74,81,84 Armin Cremerius-Günther,96,96,60,64,67,59,83 Ioan Crisiarcu,98,70,54,88,90,59,87 María Jesús Cuesta,92,54,64,85,98,59,96 Grant Culbertson,72,94,92,69,51,68,54 Scott Culp,58,76,51,62,56,74,71 Gonçalo Cunha,93,64,88,80,99,61,77 Conor Cunningham,92,62,50,59,82,56,85 Shiraz Cupala,87,68,88,93,50,91,71 Douglas Curran,80,80,51,56,79,86,93 Pawel Czernek,72,84,84,99,70,72,64 Wojciech Czupta,89,53,96,81,63,65,85

p6rt commented 15 years ago

From @finanalyst

skatersv2.pl

p6rt commented 15 years ago

From @coke

On Sat Jan 10 12​:19​:38 2009, richardh wrote​:

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286

When I run the program below, it runs and I get almost the right answer (but uninitialised values and incorrect output).

But when I comment out the 'say' line and uncomment the line below it, I get a segmentation fault.

#!/usr/local/bin/perl6

# Solution to Advanced Event 2, 2008 scripting games, http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx

use v6; my %players; my $scores = open('./skaters.txt', :r) or die $!; my $name; my @​list;

for =$scores { ($name,@​list) = .split(/\,/); @​list .=sort; %players{$name} = ([+] @​list[2..6]) / 5; };

my @​ranking = %players.sort​: { .value }; for \ -> $m { given pop @​ranking { say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_"; }; };

I don't get a segfault; I'm getting​:

Unable to open filehandle current instr.​: 'open' pc -7966446 ((unknown file)​:-1) called from Sub 'open' pc 3939 (src/classes/List.pir​:188) called from Sub 'open' pc 18003 (src/builtins/io.pir​:78) called from Sub '_block14' pc 95 (EVAL_21​:52) called from Sub '!UNIT_START' pc 16736 (src/builtins/guts.pir​:298) called from Sub 'parrot;PCT;HLLCompiler;eval' pc 950 (src/PCT/HLLCompiler.pir​:527) called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1275 (src/PCT/HLLCompiler.pir​:688) called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1456 (src/PCT/HLLCompiler.pir​:778) called from Sub 'parrot;Perl6;Compiler;main' pc 20314 (perl6.pir​:158)

this with parrot r35356.

Regards.

-- Will "Coke" Coleda

p6rt commented 15 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 15 years ago

From @pmichaud

On Sat Jan 10 12​:19​:38 2009, richardh wrote​:

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286 [...]

Try running the script using parrot directly instead of the "perl6" binary, and let us know if you still see the segfault. (The perl6 binary is known to have some issues with segfaulting, and is really more of a Parrot issue than a Rakudo one.)

For the record, on my system the program works as expected with the "say" line uncommented​:

  $ ./parrot perl6.pbc skatersv2.pl   Use of uninitialized value   Gold Medal​: , Guido Chuffart 94.2   Gold Medal​: Guido Chuffart 94.2   Use of uninitialized value   Silver Medal​: , Chase Carpenter 91.8   Silver Medal​: Chase Carpenter 91.8   Use of uninitialized value   Bronze Medal​: , Cecilia Cornejo 91.6   Bronze Medal​: Cecilia Cornejo 91.6   $

The uninitialized value warnings come from the code​:

my @​ranking = %players.sort​: { .value }; for \ -> $m { given pop @​ranking { say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_"; }; };

After sorting %players by .value, @​ranking is left as a list of Pair objects. Thus "pop @​ranking" returns a Pair, and the uninitialized value comes from using the Pair as a key in %players{$_} .

Let us know if you still see the segmentation fault when run with "parrot perl6.pbc" instead of the perl6 binary.

Thanks!

Pm

p6rt commented 15 years ago

From @finanalyst

Have you got the second data file in the current directory?

I link perl6 to /usr/local/bin, change to the directory with the text file (skaters.txt) and script (skatersv2.pl), and then run.

Richard

Will Coleda via RT wrote​:

On Sat Jan 10 12​:19​:38 2009, richardh wrote​:

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286

When I run the program below, it runs and I get almost the right answer (but uninitialised values and incorrect output).

But when I comment out the 'say' line and uncomment the line below it, I get a segmentation fault.

#!/usr/local/bin/perl6

# Solution to Advanced Event 2, 2008 scripting games, http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx

use v6; my %players; my $scores = open('./skaters.txt', :r) or die $!; my $name; my @​list;

for =$scores { ($name,@​list) = .split(/\,/); @​list .=sort; %players{$name} = ([+] @​list[2..6]) / 5; };

my @​ranking = %players.sort​: { .value }; for \ -> $m { given pop @​ranking { say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_"; }; };

I don't get a segfault; I'm getting​:

Unable to open filehandle current instr.​: 'open' pc -7966446 ((unknown file)​:-1) called from Sub 'open' pc 3939 (src/classes/List.pir​:188) called from Sub 'open' pc 18003 (src/builtins/io.pir​:78) called from Sub '_block14' pc 95 (EVAL_21​:52) called from Sub '!UNIT_START' pc 16736 (src/builtins/guts.pir​:298) called from Sub 'parrot;PCT;HLLCompiler;eval' pc 950 (src/PCT/HLLCompiler.pir​:527) called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1275 (src/PCT/HLLCompiler.pir​:688) called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1456 (src/PCT/HLLCompiler.pir​:778) called from Sub 'parrot;Perl6;Compiler;main' pc 20314 (perl6.pir​:158)

this with parrot r35356.

Regards.

p6rt commented 15 years ago

From @finanalyst

Thanks for the response.

I downloaded parrot onto my office machine (35397), and tested as you suggested. All worked and in fact I couldnt reproduce the bug!!! :((

I will try again with parrot at home with version 35286

This happened to me before - I got a segmentation fault working with a Hash; inserted a correct line of code and the fault disappeared; updated parrot and the initial fault could not be reproduced.

If it happens again, I will try parrot directly and let you know.

What is annoying is that I cant find a way to reproduce the fault with more generic code.

By the way, I have asked on the perl6-users list what the %player.sort​: {.value} means, or rather what the '​:' in that code means. I copied the idiom from Patrick's blog, but I cant find a description why it works in the Synposes.

Richard

Patrick R. Michaud via RT wrote​:

On Sat Jan 10 12​:19​:38 2009, richardh wrote​:

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286 [...]

Try running the script using parrot directly instead of the "perl6" binary, and let us know if you still see the segfault. (The perl6 binary is known to have some issues with segfaulting, and is really more of a Parrot issue than a Rakudo one.)

For the record, on my system the program works as expected with the "say" line uncommented​:

$ ./parrot perl6.pbc skatersv2.pl Use of uninitialized value Gold Medal​: , Guido Chuffart 94.2 Gold Medal​: Guido Chuffart 94.2 Use of uninitialized value Silver Medal​: , Chase Carpenter 91.8 Silver Medal​: Chase Carpenter 91.8 Use of uninitialized value Bronze Medal​: , Cecilia Cornejo 91.6 Bronze Medal​: Cecilia Cornejo 91.6 $

The uninitialized value warnings come from the code​:

my @​ranking = %players.sort​: { .value }; for \ -> $m { given pop @​ranking { say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_"; }; };

After sorting %players by .value, @​ranking is left as a list of Pair objects. Thus "pop @​ranking" returns a Pair, and the uninitialized value comes from using the Pair as a key in %players{$_} .

Let us know if you still see the segmentation fault when run with "parrot perl6.pbc" instead of the perl6 binary.

Thanks!

Pm

p6rt commented 15 years ago

From @finanalyst

Following up.

Note that you need to delete the first 'say' line and uncomment the second. Running the first 'say' line clears up the fault with the second one. Deleting the first, yields the fault.

Tried the script using parrot and perl6.pbc eliminates the fault.

Richard

Patrick R. Michaud via RT wrote​:

On Sat Jan 10 12​:19​:38 2009, richardh wrote​:

Getting a wierd segmentation fault with the following program (also attached).

I am using rakudo from parrot 35286 [...]

Try running the script using parrot directly instead of the "perl6" binary, and let us know if you still see the segfault. (The perl6 binary is known to have some issues with segfaulting, and is really more of a Parrot issue than a Rakudo one.)

For the record, on my system the program works as expected with the "say" line uncommented​:

$ ./parrot perl6.pbc skatersv2.pl Use of uninitialized value Gold Medal​: , Guido Chuffart 94.2 Gold Medal​: Guido Chuffart 94.2 Use of uninitialized value Silver Medal​: , Chase Carpenter 91.8 Silver Medal​: Chase Carpenter 91.8 Use of uninitialized value Bronze Medal​: , Cecilia Cornejo 91.6 Bronze Medal​: Cecilia Cornejo 91.6 $

The uninitialized value warnings come from the code​:

my @​ranking = %players.sort​: { .value }; for \ -> $m { given pop @​ranking { say "$m Medal​: " ~ %players{$_} ~ ', ' ~ $_; # say "$m Medal​: $_"; }; };

After sorting %players by .value, @​ranking is left as a list of Pair objects. Thus "pop @​ranking" returns a Pair, and the uninitialized value comes from using the Pair as a key in %players{$_} .

Let us know if you still see the segmentation fault when run with "parrot perl6.pbc" instead of the perl6 binary.

Thanks!

Pm

p6rt commented 15 years ago

From @pmichaud

At this point I'm guessing that the segfault seen here was due to the double-free problem in Parrot that was fixed earlier this week; so I'm marking this ticket as resolved. If it arises again, feel free to reopen this ticket or open a new one.

Thanks!

Pm

p6rt commented 15 years ago

@pmichaud - Status changed from 'open' to 'resolved'