about:benjie

Random learnings and other thoughts from an unashamed geek

PHP Segfault-ing: Preg_replace

| Comments

Update: issue now fixed.


ARGH! I cannot yet figure this one out. This code segfaults (gives memory allocation errors to) my copy of PHP, and also that on simplepie.org, but not that at php5.simplepie.org (the dev server). So there must be a difference in the PHP compilation/dependencies (as I am told that the versions of PHP are the same).

And yes, the & stuff is deliberate.

This is really frustrating. Ideas, anyone?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$attrib = "id";
$data = <<<END
&amp;amp;amp;amp;amp;nbsp; width=&amp;amp;amp;amp;amp;quot;340&amp;amp;amp;amp;amp;quot; height=&amp;amp;amp;amp;amp;quot;289&amp;amp;amp;amp;amp;quot; id=&amp;amp;amp;amp;amp;quot;player&amp;amp;amp;amp;amp;quot; align=&amp;amp;amp;amp;amp;quot;middle&amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;movie&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;http://cdn.last.fm/videoplayer/21/VideoPlayer.swf&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;menu&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;false&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;quality&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;high&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;bgcolor&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;#000000&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;allowFullScreen&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;true&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;param name=&amp;amp;amp;amp;amp;quot;flashvars&amp;amp;amp;amp;amp;quot; value=&amp;amp;amp;amp;amp;quot;creator=The+Chemical+Brothers&amp;amp;amp;amp;amp;amp;title=Do+It+Again&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;uniqueName=Do+It+Again&amp;amp;amp;amp;amp;amp;albumArt=http://cdn.last.fm/coverart/130×130/3341430-870824884.jpg&amp;amp;amp;amp;amp;amp;album=We+Are+The+Night&amp;amp;amp;amp;amp;amp;duration=278&amp;amp;amp;amp;amp;amp;image=http://panther3.last.fm/storable/videocap/7808/0/original.jpg&amp;amp;amp;amp;amp;amp;FSSupport=true&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;lt;embed src=&amp;amp;amp;amp;amp;quot;http://cdn.last.fm/videoplayer/21/VideoPlayer.swf&amp;amp;amp;amp;amp;quot;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; menu=&amp;amp;amp;amp;amp;quot;false&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; quality=&amp;amp;amp;amp;amp;quot;high&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; bgcolor=&amp;amp;amp;amp;amp;quot;#000000&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; width=&amp;amp;amp;amp;amp;quot;340&amp;amp;amp;amp;amp;quot; height=&amp;amp;amp;amp;amp;quot;289&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; name=&amp;amp;amp;amp;amp;quot;player&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; align=&amp;amp;amp;amp;amp;quot;middle&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; allowFullScreen=&amp;amp;amp;amp;amp;quot;true&amp;amp;amp;amp;amp;quot;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; flashvars=&amp;amp;amp;amp;amp;quot;creator=The+Chemical+Brothers&amp;amp;amp;amp;amp;amp;title=Do+It+Again&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;uniqueName=Do+It+Again&amp;amp;amp;amp;amp;amp;albumArt=http://cdn.last.fm/coverart/130×130/3341430-870824884.jpg&amp;amp;amp;amp;amp;amp;album=We+Are+The+Night&amp;amp;amp;amp;amp;amp;duration=278&amp;amp;amp;amp;amp;amp;image=http://panther3.last.fm/storable/videocap/7808/0/original.jpg&amp;amp;amp;amp;amp;amp;FSSupport=true&amp;amp;amp;amp;amp;quot;
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; type=&amp;amp;amp;amp;amp;quot;application/x-shockwave-flash&amp;amp;amp;amp;amp;quot; 
&amp;amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;amp;nbsp; pluginspage=&amp;amp;amp;amp;amp;quot;http://www.macromedia.com/go/getflashplayer&amp;amp;amp;amp;amp;quot; /&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;amp;lt;/object&amp;amp;amp;amp;amp;gt;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;

END;

$data = preg_replace(/ . trim($attrib) .=(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\+|{|})*/i’, ”, $data);

echo "No segfault here";

Comments