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

B::CC cannot sort #1659

Closed
p5pRT opened this issue Mar 30, 2000 · 10 comments
Closed

B::CC cannot sort #1659

p5pRT opened this issue Mar 30, 2000 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 30, 2000

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

Searchable as RT2900$

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2000

This simple program:

for $k (sort { length $ENV{$b} <=> length $ENV{$a} } keys %ENV) {
print "$k=$ENV{$k}\n";
}

Under B::Bytecode, produces correct results, then SEGVs

Under B::C, produces correct results, then exits correctly.

Under B::CC, produces no results, but goes into recursive
doom in the sort, eventually SEGVing for lack of memory
in stack death.

--tom

#0 0x4015825e in tcgetattr ()
#1 0x40158535 in tcgetattr ()
#2 0x40158d6b in malloc ()
#3 0x40061e50 in Perl_safemalloc ()
#4 0x40076cd3 in S_more_xpv ()
#5 0x40076c7c in S_new_xpv ()
#6 0x400775f1 in L273 ()
#7 0x4007adfd in Perl_sv_setpvn ()
#8 0x4007ddd6 in Perl_newSVpvn ()
#9 0x4006d160 in Perl_hv_iterkeysv ()
#10 0x400aa655 in Perl_do_kv ()
#11 0x4008926c in Perl_pp_keys ()
#12 0x69e0 in pp_main () at /tmp/sort.p.c:1152
#13 0x4006f719 in Perl_runops_standard ()
#14 0x4009b6bd in sortcv ()
#15 0x4009ae99 in S_qsortsv ()
#16 0x40093590 in Perl_pp_sort ()
#17 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#18 0x4006f719 in Perl_runops_standard ()
#19 0x4009b6bd in sortcv ()
#20 0x4009ae99 in S_qsortsv ()
#21 0x40093590 in Perl_pp_sort ()
#22 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#23 0x4006f719 in Perl_runops_standard ()
#24 0x4009b6bd in sortcv ()
#25 0x4009ae99 in S_qsortsv ()
#26 0x40093590 in Perl_pp_sort ()
#27 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#28 0x4006f719 in Perl_runops_standard ()
#29 0x4009b6bd in sortcv ()
#30 0x4009ae99 in S_qsortsv ()
#31 0x40093590 in Perl_pp_sort ()
#32 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#33 0x4006f719 in Perl_runops_standard ()
#34 0x4009b6bd in sortcv ()
#35 0x4009ae99 in S_qsortsv ()
#36 0x40093590 in Perl_pp_sort ()
#37 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#38 0x4006f719 in Perl_runops_standard ()
#39 0x4009b6bd in sortcv ()
#40 0x4009ae99 in S_qsortsv ()
#41 0x40093590 in Perl_pp_sort ()
#42 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#43 0x4006f719 in Perl_runops_standard ()
#44 0x4009b6bd in sortcv ()
#45 0x4009ae99 in S_qsortsv ()
#46 0x40093590 in Perl_pp_sort ()
#47 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#48 0x4006f719 in Perl_runops_standard ()
#49 0x4009b6bd in sortcv ()
#50 0x4009ae99 in S_qsortsv ()
#51 0x40093590 in Perl_pp_sort ()
#52 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#53 0x4006f719 in Perl_runops_standard ()
#54 0x4009b6bd in sortcv ()
#55 0x4009ae99 in S_qsortsv ()
#56 0x40093590 in Perl_pp_sort ()
#57 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#58 0x4006f719 in Perl_runops_standard ()
#59 0x4009b6bd in sortcv ()
#60 0x4009ae99 in S_qsortsv ()
#61 0x40093590 in Perl_pp_sort ()
#62 0x6a0f in pp_main () at /tmp/sort.p.c:1155
#63 0x4006f719 in Perl_runops_standard ()

[the following 25000 identical stackframes deleted]

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2000

From tchrist@chthon.perl.com

This simple program​:

  for $k (sort { length $ENV{$b} <=> length $ENV{$a} } keys %ENV) {
  print "$k=$ENV{$k}\n";
  }

Under B​::Bytecode, produces correct results, then SEGVs

Under B​::C, produces correct results, then exits correctly.

Under B​::CC, produces no results, but goes into recursive
  doom in the sort, eventually SEGVing for lack of memory
  in stack death.

--tom

#0 0x4015825e in tcgetattr ()
#1 0x40158535 in tcgetattr ()
#2 0x40158d6b in malloc ()
#3 0x40061e50 in Perl_safemalloc ()
#4 0x40076cd3 in S_more_xpv ()
#5 0x40076c7c in S_new_xpv ()
#6 0x400775f1 in L273 ()
#7 0x4007adfd in Perl_sv_setpvn ()
#8 0x4007ddd6 in Perl_newSVpvn ()
#9 0x4006d160 in Perl_hv_iterkeysv ()
#10 0x400aa655 in Perl_do_kv ()
#11 0x4008926c in Perl_pp_keys ()
#12 0x69e0 in pp_main () at /tmp/sort.p.c​:1152
#13 0x4006f719 in Perl_runops_standard ()
#14 0x4009b6bd in sortcv ()
#15 0x4009ae99 in S_qsortsv ()
#16 0x40093590 in Perl_pp_sort ()
#17 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#18 0x4006f719 in Perl_runops_standard ()
#19 0x4009b6bd in sortcv ()
#20 0x4009ae99 in S_qsortsv ()
#21 0x40093590 in Perl_pp_sort ()
#22 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#23 0x4006f719 in Perl_runops_standard ()
#24 0x4009b6bd in sortcv ()
#25 0x4009ae99 in S_qsortsv ()
#26 0x40093590 in Perl_pp_sort ()
#27 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#28 0x4006f719 in Perl_runops_standard ()
#29 0x4009b6bd in sortcv ()
#30 0x4009ae99 in S_qsortsv ()
#31 0x40093590 in Perl_pp_sort ()
#32 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#33 0x4006f719 in Perl_runops_standard ()
#34 0x4009b6bd in sortcv ()
#35 0x4009ae99 in S_qsortsv ()
#36 0x40093590 in Perl_pp_sort ()
#37 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#38 0x4006f719 in Perl_runops_standard ()
#39 0x4009b6bd in sortcv ()
#40 0x4009ae99 in S_qsortsv ()
#41 0x40093590 in Perl_pp_sort ()
#42 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#43 0x4006f719 in Perl_runops_standard ()
#44 0x4009b6bd in sortcv ()
#45 0x4009ae99 in S_qsortsv ()
#46 0x40093590 in Perl_pp_sort ()
#47 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#48 0x4006f719 in Perl_runops_standard ()
#49 0x4009b6bd in sortcv ()
#50 0x4009ae99 in S_qsortsv ()
#51 0x40093590 in Perl_pp_sort ()
#52 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#53 0x4006f719 in Perl_runops_standard ()
#54 0x4009b6bd in sortcv ()
#55 0x4009ae99 in S_qsortsv ()
#56 0x40093590 in Perl_pp_sort ()
#57 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#58 0x4006f719 in Perl_runops_standard ()
#59 0x4009b6bd in sortcv ()
#60 0x4009ae99 in S_qsortsv ()
#61 0x40093590 in Perl_pp_sort ()
#62 0x6a0f in pp_main () at /tmp/sort.p.c​:1155
#63 0x4006f719 in Perl_runops_standard ()

[the following 25000 identical stackframes deleted]

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2002

From @rspier

Dupe of #2900

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2002

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

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2005

From @schwern

[tchrist@​chthon.perl.com - Thu Mar 30 11​:30​:55 2000]​:

This simple program​:

for $k \(sort \{ length $ENV\{$b\} \<=> length $ENV\{$a\} \} keys %ENV\) \{
print "$k=$ENV\{$k\}\\n";
\} 

Under B​::Bytecode, produces correct results, then SEGVs

Now working in 5.8.6.

Under B​::C, produces correct results, then exits correctly.

Still working in 5.8.6.

Under B​::CC, produces no results, but goes into recursive
doom in the sort, eventually SEGVing for lack of memory
in stack death.

$ perlcc -O foo
/sw/bin/perlcc​: foo did not compile, which can't happen​:
Can't locate object method "_save_common_middle" via package "B​::FAKEOP"
at /sw/lib/perl5-core/5.8.6/darwin-thread-multi-2level/B/C.pm line 389.
CHECK failed--call queue aborted.

Same for bleadperl.

@p5pRT
Copy link
Author

p5pRT commented Jan 28, 2006

From guest@guest.guest.xxxxxxxx

  sub B​::OP​::_save_common_middle {
  my $op = shift;
  sprintf ("%s, %u, %u, $static, 0x%x, 0x%x",
  $op->fake_ppaddr, $op->targ, $op->type, $op->flags,
$op->private);
  }

Is the actual _save_common_middle code. Unfortuantely I don't quite
see where the inheritance is occuring for it to call that function
thusly​:

sub B​::FAKEOP​::save {
  my ($op, $level) = @​_;
  $opsect->add(sprintf("%s, %s, %s",
  $op->next, $op->sibling,
$op->_save_common_middle));
  my $ix = $opsect->index;
  $init->add(sprintf("op_list[$ix].op_ppaddr = %s;", $op->ppaddr))
  unless $optimize_ppaddr;
  return "&op_list[$ix]";
}

I tried browsing the code to see where $op-> would at all come up
relating to B​::Op, but didn't come up with anything.

@p5pRT
Copy link
Author

p5pRT commented Sep 11, 2006

@smpeters - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Jan 9, 2010

From @rurban

Ticket moved to [CPAN #53536] in the B-C queue. Please close it someone.
This simple pp_sort bug for B​::CC was fixed
in B-C-1.04_27, B​::CC 1.02_03

* CC.pm (1.02_03)​: fixed endless loop in optimized sort. The sortcv
  cmp needed a return NULL (test 19).

More pp_sort bugs are handled in
tests 18 and 25 and I'm working on it.

# 25 - simple sort
print sort { print $i++," "; $b <=> $a } 1..4
=> 0 1 2 3 4321

# 18 - custom key sort 18
my $h = { a=>3, b=>1 }; print sort {$h->{$a} <=> $h->{$b}} keys %$h
=> ba

# 19 - fool the sort optimizer by my $p. This pp_sort works ok now on CC
print sort { my $p; $b <=> $a } 1,4,3
431
--
Reini Urban

@p5pRT
Copy link
Author

p5pRT commented Jan 9, 2010

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

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2010

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant