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

multi subs compile but cause segfault #322

Closed
p6rt opened this issue Sep 17, 2008 · 11 comments
Closed

multi subs compile but cause segfault #322

p6rt opened this issue Sep 17, 2008 · 11 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 17, 2008

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

Searchable as RT58948$

@p6rt
Copy link
Author

p6rt commented Sep 17, 2008

From @stifynsemons

Using the more elaborate version of the testcase behind #​58294, which has a
two and a three argument version of max, what use to compile and execute
incorrectly before the bug fix now compiles and segfaults. I suspect this
has nothing to do with the changes that fixed #​58294, and everything to do
with recent MMD changes. But that's speculation
I've stripped it down to the max(a,b) and max(a,b,c) definitions and one
three-arg call, though a two-arg call produces a similar result. The result
is​:

sully​:perl6 stephensimmons$ perl6 experiment/max3.p6
Null PMC access in invoke()
current instr.​: '_block11' pc 44 (EVAL_14​:19)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 806
(src/PCT/HLLCompiler.pir​:481)
called from Sub 'parrot;PCT​::HLLCompiler;evalfiles' pc 1078
(src/PCT/HLLCompiler.pir​:610)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1257
(src/PCT/HLLCompiler.pir​:699)
called from Sub 'parrot;Perl6​::Compiler;main' pc 16414 (perl6.pir​:172)
perl6(22765) malloc​: *** error for object 0x343ea10​: double free
*** set a breakpoint in malloc_error_break to debug
Segmentation fault

sysinfo​:
sully​:perl6 stephensimmons$ perl6 -v
This is Rakudo Perl 6, revision 31194 built on parrot 0.7.0-devel
for darwin-thread-multi-2level.

Copyright 2006-2008, The Perl Foundation.

sully​:perl6 stephensimmons$ uname -a
Darwin sully.local 9.4.0 Darwin Kernel Version 9.4.0​: Mon Jun 9 19​:30​:53
PDT 2008; root​:xnu-1228.5.20~1/RELEASE_I386 i386

Note that this does not segfault in r30669, though it does not handle
defined correctly.

@p6rt
Copy link
Author

p6rt commented Sep 17, 2008

From @stifynsemons

max3.p6

@p6rt
Copy link
Author

p6rt commented Sep 17, 2008

From @pmichaud

On Tue, Sep 16, 2008 at 09​:01​:06PM -0700, Stephen Simmons wrote​:

Using the more elaborate version of the testcase behind #​58294, which has a
two and a three argument version of max, what use to compile and execute
incorrectly before the bug fix now compiles and segfaults. I suspect this
has nothing to do with the changes that fixed #​58294, and everything to do
with recent MMD changes. But that's speculation
I've stripped it down to the max(a,b) and max(a,b,c) definitions and one
three-arg call, though a two-arg call produces a similar result. The result
is​:

sully​:perl6 stephensimmons$ perl6 experiment/max3.p6
Null PMC access in invoke()
current instr.​: '_block11' pc 44 (EVAL_14​:19)

I think there's something wrong with Rakudo's code generation
here; see the --target=pir output for max3.p6. The code generated
for the 2-arg and 3-arg forms of max are coming out as​:

  ## 2 argument form
  .sub "max" :multi() :lexid("25") :outer("23")
  .param pmc param_16
  .param pmc param_19

  ## 3 argument form
  .sub "max" :multi() :lexid("33") :outer("23")
  .param pmc param_101
  .param pmc param_104
  .param pmc param_107

Those two empty :multi() declarations look very suspicious to me,
but I'm not familiar enough with the new MMD implementation to know
how it's supposed to work.

Pm

@p6rt
Copy link
Author

p6rt commented Sep 17, 2008

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

@p6rt
Copy link
Author

p6rt commented Sep 17, 2008

From @pmichaud

On Wed, Sep 17, 2008 at 10​:01​:12AM -0500, Patrick R. Michaud wrote​:

On Tue, Sep 16, 2008 at 09​:01​:06PM -0700, Stephen Simmons wrote​:

Using the more elaborate version of the testcase behind #​58294, which has a
two and a three argument version of max, what use to compile and execute
incorrectly before the bug fix now compiles and segfaults. I suspect this
has nothing to do with the changes that fixed #​58294, and everything to do
with recent MMD changes. But that's speculation
I've stripped it down to the max(a,b) and max(a,b,c) definitions and one
three-arg call, though a two-arg call produces a similar result. The result
is​:

sully​:perl6 stephensimmons$ perl6 experiment/max3.p6
Null PMC access in invoke()
current instr.​: '_block11' pc 44 (EVAL_14​:19)

I think there's something wrong with Rakudo's code generation
here; see the --target=pir output for max3.p6. [...]
## 2 argument form
.sub "max" :multi() :lexid("25") :outer("23")
## 3 argument form
.sub "max" :multi() :lexid("33") :outer("23")

Those two empty :multi() declarations look very suspicious to me,
but I'm not familiar enough with the new MMD implementation to know
how it's supposed to work.

I just checked with Jonathan on IRC, and he says the empty :multi()
declarations are correct here. So that's not the problem.

Actually, I suspect the problem may be that 'max' is already a
builtin function in Perl, and that the conflict comes because
the builtins (written in PIR) are still using Parrot's MultiSub
while the ones written in Perl 6 are using the new Perl6MultiSub
implementation. If I change the function name in max3.p6 to
be something other than 'max', it appears to work​:

  $ cat max3.p6
  multi sub max3($a, $b) {
  if defined $a && defined $b {
  if $a >= $b { return $a } else { return $b }
  }
  elsif defined $a { return $a }
  elsif defined $b { return $b }
  else { return undef }
  }
 
  multi sub max3($a, $b, $c) {
  return max3(max3($a, $b), $c);
  }
 
  say "6 <" ~ max3(9,2,1) ~ ">";
  $ ./parrot perl6.pbc max3.p6
  6 <9>
  $

So, this problem should be "fixed" when we get the builtins to be
written in Perl 6 (or at least using Perl6MultiSubs).

Pm

@p6rt
Copy link
Author

p6rt commented May 1, 2009

From @jnthn

On Wed Sep 17 08​:35​:08 2008, pmichaud wrote​:

Actually, I suspect the problem may be that 'max' is already a
builtin function in Perl, and that the conflict comes because
the builtins (written in PIR) are still using Parrot's MultiSub
while the ones written in Perl 6 are using the new Perl6MultiSub
implementation. If I change the function name in max3.p6 to
be something other than 'max', it appears to work​:

$ cat max3\.p6
multi sub max3\($a, $b\) \{
        if defined $a && defined $b \{
                if $a >= $b \{ return $a \} else \{ return $b \}
        \}
        elsif defined $a \{ return $a \}
        elsif defined $b \{ return $b \}
        else \{ return undef \}
\}

multi sub max3\($a, $b, $c\) \{
        return max3\(max3\($a, $b\), $c\);
\}

say "6 \<" ~ max3\(9,2,1\) ~ ">";
$ \./parrot perl6\.pbc max3\.p6
6 \<9>
$

So, this problem should be "fixed" when we get the builtins to be
written in Perl 6 (or at least using Perl6MultiSubs).

max is now moved to the setting, and the problem is indeed cleared up.
Resolving ticket.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented May 1, 2009

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

@p6rt
Copy link
Author

p6rt commented Apr 20, 2010

From @moritz

We have regressed on these tests, so I'm opening the ticket again.

@p6rt
Copy link
Author

p6rt commented Apr 20, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 5, 2010

From @moritz

Tests pass again, closing ticket again

@p6rt
Copy link
Author

p6rt commented Jul 5, 2010

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

@p6rt p6rt closed this as completed Jul 5, 2010
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant