develooper Front page | perl.perl5.porters | Postings from August 2005

Re: [PATCH] Re: [perl #36667] Lengthy parameter passed to eval leads to bus error on FreeBSD 5.4

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
August 4, 2005 16:46
Subject:
Re: [PATCH] Re: [perl #36667] Lengthy parameter passed to eval leads to bus error on FreeBSD 5.4
Message ID:
20050804234628.GA8508@iabyn.com
On Thu, Aug 04, 2005 at 09:52:18PM +0200, Dominic Dunlop wrote:
> Attached is a comprehensive but simple-minded patch that simply stops  
> Perl_peep from recursing to a depth a greater than 8192. When this  
> happens, you get a warning, and the code gets run unoptimized.

Perl_peep doesn't just do omptimisations; swome stuff is necessary for
normal running, eg

	case OP_METHOD_NAMED:
	    /* Relocate sv to the pad for thread safety.

  
> better approach would be to find out why the optimizer thinks it  
> needs such a large peephole in this case (more a picture window,  
> really) and persuade it to be less ambitious. But I don't understand  
> the optimizer at all -- hence the crude solution.


The optimiser processes ops in the order they're normally executed.
For stuff like boolean ops, there's a branch of code which isn't in the
'normal' execution path, eg

    if (foo) { bar}
    baz;

which is the same as

    foo && bar; baz;

the 'normal' path is foo -> baz. So peep recurses down the 'other' branch
to make sure it gets processed too. However, when it follows the bar path,
the next op after bar is baz, so it continues its merry way into the next
statement. Eventually it finisheds returns, and the top-level peep
continues with the next op, baz, but finds it's already been processed,
and so quits.

The fix would probably be to temporary set the 'done' flag on the next op
before recursing. But I havn't got time to look into this yet.

-- 
I've often wanted to drown my troubles, but I can't get my wife to go
swimming.

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