Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd segfaults with a small grammar #6032

Closed
p6rt opened this issue Jan 25, 2017 · 6 comments
Closed

Odd segfaults with a small grammar #6032

p6rt opened this issue Jan 25, 2017 · 6 comments
Labels
SEGV Segmentation fault, bus error, etc.

Comments

@p6rt
Copy link

p6rt commented Jan 25, 2017

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

Searchable as RT130637$

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @briandfoy

This program consistently segfaults for me​:

  grammar Grammar​::Foo {
  rule TOP {
  'z' | <unicode_escape>
  }
  token unicode_escape { '\\u' :i <[0..9a..f]> ** 4 }
  }

  my $res = Grammar​::Foo.parse( '\u2603' );

This one blows up and writes a bunch of long hex numbers to the terminal​:

  grammar Grammar​::Foo {
  rule TOP {
  'z' | <unicode_escape>
  }
  token unicode_escape { 'u' :i <[0..9a..f]> ** 4 }
  }

  my $res = Grammar​::Foo.parse( 'u2603' );

I stripped this down from a much larger thing I was working on, and
if I remove anything else I don't have the problem.

And, some details​:

  $ perl6 -v
  This is Rakudo version 2016.11 built on MoarVM version 2016.11
  implementing Perl 6.c.
  $ uname -a
  Darwin macpro.local 14.5.0 Darwin Kernel Version 14.5.0

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @AlexDaniel

FWIW, Bisectable points to rakudo/rakudo@d5c6b61

On 2017-01-24 22​:58​:44, comdog wrote​:

This program consistently segfaults for me​:

grammar Grammar​::Foo {
rule TOP {
'z' | <unicode_escape>
}
token unicode_escape { '\\u' :i <[0..9a..f]> ** 4 }
}

my $res = Grammar​::Foo.parse( '\u2603' );

This one blows up and writes a bunch of long hex numbers to the terminal​:

grammar Grammar​::Foo {
rule TOP {
'z' | <unicode_escape>
}
token unicode_escape { 'u' :i <[0..9a..f]> ** 4 }
}

my $res = Grammar​::Foo.parse( 'u2603' );

I stripped this down from a much larger thing I was working on, and
if I remove anything else I don't have the problem.

And, some details​:

$ perl6 -v
This is Rakudo version 2016.11 built on MoarVM version 2016.11
implementing Perl 6.c.
$ uname -a
Darwin macpro.local 14.5.0 Darwin Kernel Version 14.5.0

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

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

@p6rt
Copy link
Author

p6rt commented Jan 31, 2017

From @jnthn

On Tue, 24 Jan 2017 22​:58​:44 -0800, comdog wrote​:

This program consistently segfaults for me​:

grammar Grammar&#8203;::Foo \{
    rule TOP \{
        'z' | \<unicode\_escape>
        \}
    token unicode\_escape \{ '\\\\u' :i \<\[0\.\.9a\.\.f\]> \*\* 4 \}
    \}

my $res = Grammar&#8203;::Foo\.parse\( '\\u2603' \);

This one blows up and writes a bunch of long hex numbers to the terminal​:

grammar Grammar&#8203;::Foo \{
    rule TOP \{
        'z' | \<unicode\_escape>
        \}
    token unicode\_escape \{ 'u' :i \<\[0\.\.9a\.\.f\]> \*\* 4 \}
    \}

my $res = Grammar&#8203;::Foo\.parse\( 'u2603' \);

I stripped this down from a much larger thing I was working on, and
if I remove anything else I don't have the problem.

And, some details​:

$ perl6 \-v
This is Rakudo version 2016\.11 built on MoarVM version 2016\.11
implementing Perl 6\.c\.
$ uname \-a
Darwin macpro\.local 14\.5\.0 Darwin Kernel Version 14\.5\.0

It golfs further still, it seems. This one also blows up​:

grammar Grammar​::Foo {
  token TOP {
  'z' | :i <[0..9]> ** 4
  }
}
my $res = Grammar​::Foo.parse( '2603' );

And is fixed by the removal of the :i, so that's likely playing a role. Will dig further.

@p6rt
Copy link
Author

p6rt commented Jan 31, 2017

From @jnthn

On Tue, 31 Jan 2017 08​:21​:34 -0800, jnthn@​jnthn.net wrote​:

It golfs further still, it seems. This one also blows up​:

grammar Grammar​::Foo {
token TOP {
'z' | :i <[0..9]> ** 4
}
}
my $res = Grammar​::Foo.parse( '2603' );

And is fixed by the removal of the :i, so that's likely playing a
role. Will dig further.

Fixed and covered by tests in S05-metasyntax/longest-alternative.t. The SEGV was due to a lack of validation during NFA construction; fixing that turned it into an error, which was in turn fixed by correcting a bug in the regex to NFA compiler that left a dangling edge. The additional validation caught a second bug, which is also fixed and now spectest covered in the same file.

@p6rt
Copy link
Author

p6rt commented Jan 31, 2017

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

@p6rt p6rt closed this as completed Jan 31, 2017
@p6rt p6rt added the SEGV Segmentation fault, bus error, etc. label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SEGV Segmentation fault, bus error, etc.
Projects
None yet
Development

No branches or pull requests

1 participant