develooper Front page | perl.perl5.porters | Postings from February 2008

Re: Assistance with IPC modules and perl 5.10

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
February 22, 2008 05:44
Subject:
Re: Assistance with IPC modules and perl 5.10
Message ID:
20080222134349.GW38653@plum.flirble.org
On Mon, Feb 18, 2008 at 09:52:08PM +0000, Andy Armstrong wrote:
> On 18 Feb 2008, at 21:46, H.Merijn Brand wrote:
> >Just out of curiousity, I did a build on my 64bitall bleadperl
> >on OpenSUSE 10.2:
> 
> [snip success]
> 
> Hmm. There's certainly not a complete correlation between failures and  
> 64 bit platforms:
> 
> http://cpantesters.perl.org/show/IPC-ShareLite.html

Does the appended fix it?

The issue seems to be that on read, IPC ShareLite allocates a contiguous block
of memory to copy the shared memory into, then passes that memory back into
perl:

    ST(0) = sv_newmortal();
    if (length >= 0) {
      sv_usepvn((SV*)ST(0), data, length);
    } else {
      sv_setsv(ST(0), &PL_sv_undef);
    }

[and from inspection, that second sv_setsv is unnecessary, as the default
state of a new mortal is undef.]

For ages the perl core has used a wrapper to malloc(), which may or may not
be the system malloc. (And certainly isn't under Win32, but this isn't Win32)

However, with 5.10, under -DDEBUGGING that has changed - the internal malloc
wrapper now adds debugging headers, and passes back a pointer within the
block allocated by the system malloc.

IPC::ShareLite isn't playing along with this, as it passes in a pointer
allocated by the (unwrapped) system malloc.

> Does it fail on 32 bit FC too Tom?

Does this mean the FC is going to be shipping its default perl with -DDEBUGGING
in the C flags? That will make it slow.

Nicholas Clark

--- sharelite.c~	2000-04-14 12:24:00.000000000 +0200
+++ sharelite.c	2008-02-22 14:33:51.000000000 +0100
@@ -329,7 +329,7 @@
   node   = share->head;
   left = length = node->shmaddr->length;
 
-  if ((pos = *data = (char *) malloc( length )) == NULL)
+  if ((pos = *data = (char *) Perl_safesysmalloc( length )) == NULL)
     return -1;
 
   while(left) {



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About