Skip Menu |

This queue is for tickets about the Proc-ProcessTable CPAN distribution.

Report information
The Basics
Id: 99163
Status: resolved
Priority: 0/
Queue: Proc-ProcessTable

People
Owner: Nobody in particular
Requestors: ianburrell [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.50
Fixed in: (no value)



Subject: Segfault on Perl 5.20.1
Doesn't happen every time but happens after long run of test suite. Code is: my $proc = Proc::ProcessTable->new(); foreach my $process (@{$proc->table()}) { return $process->rss() / 1024 if ($process->pid() == $PID) } Stack trace: (gdb) bt #0 0x000000391144812c in _IO_vfprintf_internal (s=<value optimized out>, format=<value optimized out>, ap=<value optimized out>) at vfprintf.c:1641 #1 0x000000391146fcb7 in _IO_obstack_vprintf (obstack=0x7fffe3815360, format=0x7f8d38e3cd06 "%s", args=0x7fffe3815000) at obprintf.c:171 #2 0x000000391146fda8 in _IO_obstack_printf (obstack=<value optimized out>, format=<value optimized out>) at obprintf.c:188 #3 0x00007f8d38e3a3d3 in eval_link () from /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear-perl520-LINUPGRADE-248/local/lib/perl5/x86_64-linux/auto/Proc/ProcessTable/ProcessTable.so #4 0x00007f8d38e3aef4 in OS_get_table () from /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear-perl520-LINUPGRADE-248/local/lib/perl5/x86_64-linux/auto/Proc/ProcessTable/ProcessTable.so #5 0x00007f8d38e3c25f in XS_Proc__ProcessTable_table () from /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear-perl520-LINUPGRADE-248/local/lib/perl5/x86_64-linux/auto/Proc/ProcessTable/ProcessTable.so #6 0x00000000004a5188 in Perl_pp_entersub () #7 0x00000000004a39e3 in Perl_runops_standard () #8 0x0000000000437f6e in perl_run () #9 0x000000000041ce1c in main ()
Can you supply some additional details e.g. the output of $ perl -V And as second question: How long is long, do you mean your test suite runs a day or an hour or perhaps a month? Best, Joachim On Fri Sep 26 15:34:32 2014, ianburrell@gmail.com wrote: Show quoted text
> Doesn't happen every time but happens after long run of test suite. > > Code is: > > my $proc = Proc::ProcessTable->new(); > foreach my $process (@{$proc->table()}) { > return $process->rss() / 1024 if ($process->pid() == $PID) > } > > Stack trace: > > (gdb) bt > #0 0x000000391144812c in _IO_vfprintf_internal (s=<value optimized
> out>,
> format=<value optimized out>, ap=<value optimized out>) at > vfprintf.c:1641 > #1 0x000000391146fcb7 in _IO_obstack_vprintf > (obstack=0x7fffe3815360, > format=0x7f8d38e3cd06 "%s", args=0x7fffe3815000) at obprintf.c:171 > #2 0x000000391146fda8 in _IO_obstack_printf (obstack=<value > optimized out>, > format=<value optimized out>) at obprintf.c:188 > #3 0x00007f8d38e3a3d3 in eval_link () > from > /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear- > perl520-LINUPGRADE-248/local/lib/perl5/x86_64- > linux/auto/Proc/ProcessTable/ProcessTable.so > #4 0x00007f8d38e3aef4 in OS_get_table () > from > /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear- > perl520-LINUPGRADE-248/local/lib/perl5/x86_64- > linux/auto/Proc/ProcessTable/ProcessTable.so > #5 0x00007f8d38e3c25f in XS_Proc__ProcessTable_table () > from > /mnt/iscsi/vol_na4_lindev_lun/lindev4/data_storage/work/imb/linear- > perl520-LINUPGRADE-248/local/lib/perl5/x86_64- > linux/auto/Proc/ProcessTable/ProcessTable.so > #6 0x00000000004a5188 in Perl_pp_entersub () > #7 0x00000000004a39e3 in Perl_runops_standard () > #8 0x0000000000437f6e in perl_run () > #9 0x000000000041ce1c in main ()
We also ran into a segv with very similar stacktrace, eventually boils down into this small code snippet that can reproduce segv. The OS is Linux (CentoOS and Ubuntu) ------------------------ #!/usr/bin/env perl use strict; use Proc::ProcessTable; my $data = {}; my $x = "a" x 2000; for my $n (1..1_500_000) { $data->{$n} = $x; } my $p = Proc::ProcessTable->new( 'cache_ttys' => 1 ); my $table = $p->table; ------------------------- If you change the large constant 1_500_000 to be something smaller it does not happen. We traced a bit and eventuallly came into OS.c L387 link = canonicalize_file_name(link_file); The value in in this `link` might be bogus if pid is the current pid ($$) of ppid (but that's gdb) In other pid, link is just NULL (because we got permission denied when reding /proc/$pid/$something)
Apparently I made a mistake a marked "Fixed In" for 3 versions, while I meant to say thoese versions still suffers from this issue. related material: https://github.com/jwbargsten/perl-proc-processtable/pull/8
Pulled the patch on github. It should work now. I've bumped the patched Proc::ProcessTable to version 0.51 and uploaded it to CPAN. Thanks everybody for the help, I'm quite amazed how well this bug was solved by the community.