Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: jloverso [...] mathworks.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 0.40
  • 0.41
Fixed in: 0.43



Subject: 0.41 segfaults on MacOS 10.4.x (i386 and ppc)
Download (untitled) / with headers
text/plain 943b
'make test' failed for me on ppc/10.4.7, but passed on ppc/10.3.8 and i386/10.4.7. On all three platforms, when I used Proc::ProcessTable in an app, it would seg fault (included with the example.pl script). os/darwin.c loops over the returned kinfo_proc structures - but someone reversed the loop and accidentally left the index counter starting at 1: nentries = bufSize/ sizeof(struct kinfo_proc); kinfo = malloc(nentries * sizeof(KINFO)); ... #if 1 kp += nentries - 1; for (i = 1; i <= nentries; i++, --kp) { #else for (i = nentries; --i >= 0; ++kp) { #endif ... ki = &kinfo[i]; So the last proc will overshoot the kinfo array by 1. The simple fix is to change the code to use 'i = 0;' -- but if you look closer, you'll see the whole kinfo array is never used. Only 1 entry is used at a time. The enclosed patch just removes the kinfo array and uses a single KINFO structure.
Subject: Proc-ProcessTable-darwin.patch
==== //3rdparty/tmw/perl-modules/Proc-ProcessTable/os/darwin.c#1 - /mathworks/devel/sandbox/jloverso/ws/3rdparty/tmw/perl-modules/Proc-ProcessTable/os/darwin.c ==== 88d87 < if (kinfo != NULL) free (kinfo); \ 97d95 < KINFO *kinfo = NULL; 139,142d136 < if ((kinfo = malloc(nentries * sizeof(KINFO))) == NULL) < DIE_HORRIBLY ("Memory allocation failure") < memset(kinfo, 0, (nentries * sizeof(*kinfo))); < 146a141 > 155c150,152 < KINFO *ki; --- > KINFO kinfo; > KINFO *ki = &kinfo; > memset(ki, 0, sizeof(*ki)); 162d158 < ki = &kinfo[i];
Download (untitled) / with headers
text/plain 404b
My apologies for the extreme delay in responding. The off-by-one error was previously reported, but for some reason did not make it into 0.42. Your simplification is well-spotted, and incorporated into the attached tarball, which contains all Darwin-specific files. The only actual changes from 0.42 are os/darwin.c and os/darwin.h. These files also incorporate the changes for tickets 32761 and 33698.

Message body not shown because it is not plain text.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.