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

Newbie code segfaults #5185

Closed
p6rt opened this issue Mar 20, 2016 · 5 comments
Closed

Newbie code segfaults #5185

p6rt opened this issue Mar 20, 2016 · 5 comments
Labels
SEGV Segmentation fault, bus error, etc.

Comments

@p6rt
Copy link

p6rt commented Mar 20, 2016

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

Searchable as RT127748$

@p6rt
Copy link
Author

p6rt commented Mar 20, 2016

From @lizmat

==========================
my $a = 14;
while (True) {
  my $z = (2..13).first(-> $x { !($a %% $x) });
  last if (!$z);
  $a += 14
}
say $a

The above code “verbatim” segfaults on OS X and Linux on HEAD.

Replacing either the (True) by True, or (!$z) by !$z, or adding an additional say after the loop, will make the code succeed.

Looking at the output of —target=optimize between (!$z) and !$z, I see only this significant difference​:

- - QAST​::Op(callstatic &prefix​:<!>) :BY<modifier_expr W> :statement_id<?> :WANTED !
+ - QAST​::Op(callstatic &prefix​:<!>) :BY<modifier_expr W> :WANTED !

I would have sorta expected that the () would not make a difference for the generated code at all, but apparently it does?

Also, disabling spesh or JIT does not seem to make a difference.

In any case, I thought this would be a nice thing for the right people. :-)

Discussion at​: http://irclog.perlgeek.de/perl6/2016-03-20#i_12212186

Liz

@p6rt
Copy link
Author

p6rt commented Mar 20, 2016

From @lizmat

On 20 Mar 2016, at 14​:39, Elizabeth Mattijsen (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Elizabeth Mattijsen
# Please include the string​: [perl #​127748]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127748 >

==========================
my $a = 14;
while (True) {
my $z = (2..13).first(-> $x { !($a %% $x) });
last if (!$z);
$a += 14
}
say $a

Some more datapoints​:

Changing the first block to

  { !($a %% $^x) }

does *not* fix the issue, changing the block to

  { !($a %% $_) }

*does* fix the issue.

Also, changing the type of $a to​:

  my Int $a = 14;

does *not* fix the issue, whereas changing it to​:

  my int $a = 14;

*does* fix the issue.

Liz

@p6rt
Copy link
Author

p6rt commented Apr 1, 2016

From @jnthn

On Sun Mar 20 06​:39​:39 2016, elizabeth wrote​:

==========================
my $a = 14;
while (True) {
my $z = (2..13).first(-> $x { !($a %% $x) });
last if (!$z);
$a += 14
}
say $a

The above code “verbatim” segfaults on OS X and Linux on HEAD.

Replacing either the (True) by True, or (!$z) by !$z, or adding an
additional say after the loop, will make the code succeed.

Looking at the output of —target=optimize between (!$z) and !$z, I see
only this significant difference​:

- - QAST​::Op(callstatic &prefix​:<!>) :BY<modifier_expr W>
:statement_id<?> :WANTED !
+ - QAST​::Op(callstatic &prefix​:<!>) :BY<modifier_expr W> :WANTED !

I would have sorta expected that the () would not make a difference
for the generated code at all, but apparently it does?

Also, disabling spesh or JIT does not seem to make a difference.

In any case, I thought this would be a nice thing for the right
people. :-)

Discussion at​: http://irclog.perlgeek.de/perl6/2016-03-20#i_12212186

Was a GC invariant violation that occasionally led to memory corruption (thus why it was easy to make it vanish with silly changes). Actually a regression within the last month or two. Fixed it, and add a test to integration/weird-errors.t.

/jnthn

@p6rt
Copy link
Author

p6rt commented Apr 1, 2016

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

@p6rt p6rt closed this as completed Apr 1, 2016
@p6rt
Copy link
Author

p6rt commented Apr 1, 2016

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

@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