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

Segfault when make()ing things in a when-block in grammar actions #838

Closed
p6rt opened this issue Mar 25, 2009 · 7 comments
Closed

Segfault when make()ing things in a when-block in grammar actions #838

p6rt opened this issue Mar 25, 2009 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Mar 25, 2009

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

Searchable as RT64208$

@p6rt
Copy link
Author

p6rt commented Mar 25, 2009

From @moritz

In a parser I am writing I see a segmentation fault that shows up on a
piece of code like this​:

method value($/, $what) {
  when * { make 1 } ;
}

(adding a given $what { ... } around it makes no difference). When I
write instead a simple 'make 1' or 'do { do { make 1 } }', it does not
segfault.

To reproduce this problem, do these steps​:
git clone git​://github.com/moritz/json.git
cd json
PERL6LIB=/path/to/your/rakudo/dir perl6 t/structure.t

This is the backtrace I get from running it with gdb​:
[New Thread 0x7f47461b06f0 (LWP 25506)]
1..1

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f47461b06f0 (LWP 25506)]
0x00007f4745908920 in Parrot_callmethodcc_p_sc (cur_opcode=0x7f4746007390,
  interp=0x237a010) at src/ops/object.ops​:59
59 PMC * const method_pmc = VTABLE_find_method(interp,
object, meth);
(gdb) bt
#​0 0x00007f4745908920 in Parrot_callmethodcc_p_sc
(cur_opcode=0x7f4746007390,
  interp=0x237a010) at src/ops/object.ops​:59
#​1 0x00007f47459dcf85 in runops_slow_core (interp=0x237a010,
  pc=0x7f4746007390) at src/runops_cores.c​:461
#​2 0x00007f474598a315 in runops_int (interp=0x237a010, offset=468)
  at src/interpreter.c​:980
#​3 0x00007f474598ae1a in runops (interp=0x237a010, offs=468)
  at src/call/ops.c​:107
#​4 0x00007f474598b1f6 in runops_args (interp=0x237a010,
sub=0x7f4741bda090,
  obj=0x2405810, meth_unused=0x0, sig=0x7f4745c17124 "vP",
ap=0x7fff4e1d7270)
  at src/call/ops.c​:254
#​5 0x00007f474598c5ac in Parrot_runops_fromc_args (interp=0x237a010,
  sub=0x7f4741bda090, sig=0x7f4745c17124 "vP") at src/call/ops.c​:321
#​6 0x00007f474596979f in Parrot_ex_throw_from_c (interp=0x237a010,
  exception=0x7f4741bd9f70) at src/exceptions.c​:341
#​7 0x00007f4745969974 in Parrot_ex_throw_from_c_args (interp=0x237a010,
  ret_addr_unused=0x0, exitcode=51,
  format=0x7f4745c1e790 "can't convert unicode string to ascii")
  at src/exceptions.c​:410
#​8 0x00007f4745a84003 in to_ascii (interp=0x237a010, src=0x4707528,
  dest=0x47074e0) at src/string/charset/ascii.c​:279
#​9 0x00007f4745a84989 in to_charset (interp=0x237a010, src=0x4707528,
  dest=0x47074e0) at src/string/charset/ascii.c​:340
#​10 0x00007f47458e89e1 in Parrot_str_change_charset (interp=0x237a010,
  src=0x4707528, charset_nr=0, dest=0x47074e0) at src/string/api.c​:2963
#​11 0x00007f474590feca in Parrot_trans_charset_s_s_i (
  cur_opcode=0x7f4740e77028, interp=0x237a010) at src/ops/string.ops​:555
#​12 0x00007f47459dcf85 in runops_slow_core (interp=0x237a010,
  pc=0x7f4740e77028) at src/runops_cores.c​:461
#​13 0x00007f474598a315 in runops_int (interp=0x237a010, offset=21854)
  at src/interpreter.c​:980
#​14 0x00007f474598ae1a in runops (interp=0x237a010, offs=21854)
  at src/call/ops.c​:107
#​15 0x00007f474598b1f6 in runops_args (interp=0x237a010,
sub=0x7f4742c28390,
  obj=0x2405810, meth_unused=0x0, sig=0x7f4745c168ab "vP",
ap=0x7fff4e1d77a0)
  at src/call/ops.c​:254
#​16 0x00007f474598c5ac in Parrot_runops_fromc_args (interp=0x237a010,
  sub=0x7f4742c28390, sig=0x7f4745c168ab "vP") at src/call/ops.c​:321
#​17 0x00007f4745965d3e in Parrot_runcode (interp=0x237a010, argc=2,
  argv=0x7fff4e1d79d8) at src/embed.c​:1011
#​18 0x0000000000400cbd in main ()

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Apr 28, 2009

From @pmichaud

I think this bug should now be fixed in 456ade5 -- it no longer
segfaults on the test program I'm giving it. The problem appears to
have been that 'when' statements (and 'loop' and 'repeat') were failing
to create the implicit $/ lexical var (as well as $_ and $!), and thus
the 'make' function would segfault when attempting to set $/.ast .

The test program I was using no longer segfaults as of 456ade5​:

$ cat x
grammar A {
  regex TOP { \' (.*?) \' {*} }
};

class B {
  method TOP($/) {
  when * {
  make ['Text', ~$0];
  }
  }
};

A.parse("'foo'", :action(B.new))
  or die 'no match'; say $/.ast.perl;

$ ./perl6 x
["Text", "foo"]
$

I'll assign the ticket to moritz++, who can then decide what spectests
(if any) we need and then close the ticket.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Apr 28, 2009

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

@p6rt
Copy link
Author

p6rt commented Apr 28, 2009

From @coke

On Mon, Apr 27, 2009 at 8​:10 PM, Patrick R. Michaud via RT
<perl6-bugs-followup@​perl.org> wrote​:

I think this bug should now be fixed in 456ade5 -- it no longer
segfaults on the test program I'm giving it.  The problem appears to
have been that 'when' statements (and 'loop' and 'repeat') were failing
to create the implicit $/ lexical var (as well as $_ and $!), and thus
the 'make' function would segfault when attempting to set $/.ast .

The test program I was using no longer segfaults as of 456ade5​:

$ cat x
grammar A {
   regex TOP { \' (.*?) \' {*} }
};

class B {
   method TOP($/) {
       when * {
           make ['Text', ~$0];
       }
   }
};

A.parse("'foo'", :action(B.new))
   or die 'no  match'; say $/.ast.perl;

$ ./perl6 x
["Text", "foo"]
$

I'll assign the ticket to moritz++, who can then decide what spectests
(if any) we need and then close the ticket.

Thanks!

Pm

Is the segfault something that can be generated in pure parrot, or
does it require perl6 C code to trip?

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Apr 28, 2009

From @pmichaud

On Mon, Apr 27, 2009 at 08​:45​:47PM -0400, Will Coleda wrote​:

On Mon, Apr 27, 2009 at 8​:10 PM, Patrick R. Michaud via RT
<perl6-bugs-followup@​perl.org> wrote​:

I think this bug should now be fixed in 456ade5 -- it no longer
segfaults on the test program I'm giving it.  
[...]
I'll assign the ticket to moritz++, who can then decide what spectests
(if any) we need and then close the ticket.

Is the segfault something that can be generated in pure parrot, or
does it require perl6 C code to trip?

It can be generated in pure parrot -- I still need to extract out
the case that was causing the segfault.

Pm

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

From @moritz

Tested in S05-grammar/action-stubs.t.

If you want a ticket for parrot tests, please open a track ticket.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

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

@p6rt p6rt closed this as completed Apr 29, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant