develooper Front page | perl.perl5.porters | Postings from December 2012

Re: perl smokes with -DPERL_GLOBAL_STRUCT (or-DPERL_GLOBAL_STRUCT_PRIVATE)?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
December 3, 2012 14:00
Subject:
Re: perl smokes with -DPERL_GLOBAL_STRUCT (or-DPERL_GLOBAL_STRUCT_PRIVATE)?
Message ID:
20121203140026.GG5653@plum.flirble.org
On Sun, Nov 25, 2012 at 09:44:19AM -0500, Jarkko Hietaniemi wrote:
> Hi, I wonder if any one the numerous Perl smokes is building with
> -DPERL_GLOBAL_STRUCT, or even more hardcore,
> -DPERL_GLOBAL_STRUCT_PRIVATE?  They were originally conceived for the
> Symbian port, they hide/remove all global data symbols (global
> variables), turning the embeddability to eleven and twelve, if you
> will.  (If compile barfs, needs more dVAR: see perlguts for more
> information.)
> 
> The Symbian port is of course of dubious value any more, and probably
> does not work any more for any of the more recent Symbian releases,
> but I think trying to keep this ultimate embeddability option alive
> would be good.  (Similarly, checking what "nm libperl.a | grep -v '
> [TURtr] '" says once in a while is good hygiene.)

From what I read of the punditry, based on sales numbers, a Symbian port
generally is likely of more use than Windows Phone (7 or 8). :-(

Shame that it's unlikely to work on current Symbian.

On Sun, Nov 25, 2012 at 10:38:06PM -0500, George Greer wrote:
> On Sun, 25 Nov 2012, Jarkko Hietaniemi wrote:
> 
> > Hi, I wonder if any one the numerous Perl smokes is building with
> > -DPERL_GLOBAL_STRUCT, or even more hardcore,
> > -DPERL_GLOBAL_STRUCT_PRIVATE?  They were originally conceived for the
> > Symbian port, they hide/remove all global data symbols (global
> > variables), turning the embeddability to eleven and twelve, if you
> > will.  (If compile barfs, needs more dVAR: see perlguts for more
> > information.)
> 
> I recently added PERL_GLOBAL_STRUCT (and PERL_OLD_COPY_ON_WRITE) to my 
> non-quick smokers but I just thought of a way to add 
> PERL_GLOBAL_STRUCT_PRIVATE too without causing too much extra build time 
> so I'll do that too.


IIRC I tried -DPERL_GLOBAL_STRUCT_PRIVATE a while back (for some unrelated
reason) and hit a problem that I couldn't work out how to solve.

I've trust tried building on x86_64 Linux, and I can't get beyond miniperl,
due to a SEGV.

A rather simple demonstration of the problem:

$ valgrind ./miniperl -e0
==20724== Memcheck, a memory error detector
==20724== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==20724== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==20724== Command: ./miniperl -e0
==20724==
==20724== Conditional jump or move depends on uninitialised value(s)
==20724==    at 0x405394: S_init_tls_and_interp (perl.c:99)
==20724==    by 0x4057A3: perl_alloc (perl.c:209)
==20724==    by 0x435358: main (miniperlmain.c:104)
==20724==
==20724== Invalid read of size 4
==20724==    at 0x405691: Perl_sys_term (perl.c:154)
==20724==    by 0x435490: main (miniperlmain.c:145)
==20724==  Address 0x5e81254 is 532 bytes inside a block of size 632 free'd
==20724==    at 0x4C2475F: free (vg_replace_malloc.c:427)
==20724==    by 0x4BEE45: Perl_free_global_struct (util.c:5762)
==20724==    by 0x43548B: main (miniperlmain.c:142)


The first is the read of PL_curinterp here:

static void
S_init_tls_and_interp(PerlInterpreter *my_perl)
{
    dVAR;
    if (!PL_curinterp) {			
	PERL_SET_INTERP(my_perl);


The second is the read of PL_veto_cleanup here:

void
Perl_sys_term()
{
    dVAR;
    if (!PL_veto_cleanup) {
	PERL_SYS_TERM_BODY();
    }
}



I get the same failures with or without ithreads. I have a nasty suspicion
that -DPERL_GLOBAL_STRUCT_PRIVATE may always only have actually have worked
due to the nasal daemons being lethargic. :-(

I'm really not sure how to fix it. Careful special casing of all the
bootstrap/teardown code that has to run before the private global structure
is allocated, and after it is deallocated?

Nicholas Clark

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