#24175 [Fbk->Opn]: String overflow? Segmentation faults
ID: 24175 User updated by: justinlong at strategicnetwork dot org Reported By: justinlong at strategicnetwork dot org -Status: Feedback +Status: Open Bug Type: Reproducible crash Operating System: KRUD/RedHat PHP Version: 4.3.2 New Comment: On the basis of your snippy reply I presume I have not communicated clearly the error that I am encountering. This is the only script which causes this problem. The point where it occurs is toward the end at the line if (strlen($story)>512) { echo $rec->headline,"\n"; } pg_exec($db,"UPDATE story_headline SET story_preprocessed=$todaySystem, story='".addslashes($story)."' WHERE storyid=".$rec->storyid); But obviously it's not these two lines which cause the problem since the crash does not occur on one specific entry in the database but rather at different points in the run each time. This the only script which crashes; I don't encounter this problem anywhere else. Previous Comments: [2003-06-13 09:16:48] [EMAIL PROTECTED] What in the 'short and _complete_ stand-alone script did you not understand? You must give us the exact piece of code that causes the crash, NOT the whole script. [2003-06-13 09:09:47] justinlong at strategicnetwork dot org #!/usr/local/bin/php -q preprocessing > 0) { die(); } else { $rs = pg_exec($db,"UPDATE story_progress SET preprocessing=".$todaySystem); } set_time_limit(0); $rs = pg_exec($db,"SELECT count(storyid) from story_headline WHERE article IS NOT NULL and story_preprocessed IS NULL"); $rec = pg_fetch_object($rs,0); echo $rec->count,' records unprocessed',"\n"; //$rs = pg_exec($db,"SELECT storyid,headline,article from story_headline WHERE storyid=80493 limit 1000"); $rs = pg_exec($db,"SELECT storyid,headline,article from story_headline WHERE article IS NOT NULL and story_preprocessed IS NULL order by storyid desc limit 100"); if ($rs && pg_numrows($rs)>0) { for ($x=0;$xstoryid,' ',$rec->headline," "; $article = trim(stripslashes($rec->article)); if (strlen($article)>512) { $article = str_replace("]+>","\n\n\n",$article); $article = eregi_replace("]+>","\n\n",$article); $article = html_entity_decode($article); // get rid of HTML entities $article = eregi_replace("&[^;]+;"," ",$article); // get rid of control characters if (!empty($article)) { $article = strtr($article, "¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAACDNOOYsaaaconooyy"); } if (!empty($article)) { $article = strip_tags($article,''); $article = " ".$article; $textlines = split("")>0) { $nextstory = substr($nextstory,strpos($nextstory,">")+1); } $checklines = split("\n",$nextstory); if (count($checklines)>0) { $totallength=1; $totallines=1; $totalsingletones=1; for ($y=0;$y0) { $totallines++; $totallength = $totallength + strlen($checklines[$y]); if ($checklines[$y] == "") { $totalsingletones++; } } } if ($totallength/$totallines>15 && $totalsingletons/$totallines<.5 && strlen($nextstory)>512) { $nextstory = $story .= trim(strip_tags($nextstory))." \n\n"; } } } } } if (strlen($story)>512) { echo $rec->headline,"\n"; } pg_exec($db,"UPDATE story_headline SET story_preprocessed=$todaySystem, story='".addslashes($story)."' WHERE storyid=".$rec->storyid); } } $rs = pg_exec($db,"UPDATE story_progress SET preprocessing=NULL"); pg_exec($db,"ANALYZE story_headline"); pg_exec($db,"ANALYZE story_site"); ?> [2003-06-13 09:07:32] [EMAIL PROTECTED] Please provide a short but _complete_ stand-alone script.
#24175 [Fbk->Opn]: String overflow? Segmentation faults
ID: 24175 User updated by: justinlong at strategicnetwork dot org Reported By: justinlong at strategicnetwork dot org -Status: Feedback +Status: Open Bug Type: Reproducible crash Operating System: KRUD/RedHat PHP Version: 4.3.2 New Comment: #!/usr/local/bin/php -q preprocessing > 0) { die(); } else { $rs = pg_exec($db,"UPDATE story_progress SET preprocessing=".$todaySystem); } set_time_limit(0); $rs = pg_exec($db,"SELECT count(storyid) from story_headline WHERE article IS NOT NULL and story_preprocessed IS NULL"); $rec = pg_fetch_object($rs,0); echo $rec->count,' records unprocessed',"\n"; //$rs = pg_exec($db,"SELECT storyid,headline,article from story_headline WHERE storyid=80493 limit 1000"); $rs = pg_exec($db,"SELECT storyid,headline,article from story_headline WHERE article IS NOT NULL and story_preprocessed IS NULL order by storyid desc limit 100"); if ($rs && pg_numrows($rs)>0) { for ($x=0;$xstoryid,' ',$rec->headline," "; $article = trim(stripslashes($rec->article)); if (strlen($article)>512) { $article = str_replace("]+>","\n\n\n",$article); $article = eregi_replace("]+>","\n\n",$article); $article = html_entity_decode($article); // get rid of HTML entities $article = eregi_replace("&[^;]+;"," ",$article); // get rid of control characters if (!empty($article)) { $article = strtr($article, "¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAACDNOOYsaaaconooyy"); } if (!empty($article)) { $article = strip_tags($article,''); $article = " ".$article; $textlines = split("")>0) { $nextstory = substr($nextstory,strpos($nextstory,">")+1); } $checklines = split("\n",$nextstory); if (count($checklines)>0) { $totallength=1; $totallines=1; $totalsingletones=1; for ($y=0;$y0) { $totallines++; $totallength = $totallength + strlen($checklines[$y]); if ($checklines[$y] == "") { $totalsingletones++; } } } if ($totallength/$totallines>15 && $totalsingletons/$totallines<.5 && strlen($nextstory)>512) { $nextstory = $story .= trim(strip_tags($nextstory))." \n\n"; } } } } } if (strlen($story)>512) { echo $rec->headline,"\n"; } pg_exec($db,"UPDATE story_headline SET story_preprocessed=$todaySystem, story='".addslashes($story)."' WHERE storyid=".$rec->storyid); } } $rs = pg_exec($db,"UPDATE story_progress SET preprocessing=NULL"); pg_exec($db,"ANALYZE story_headline"); pg_exec($db,"ANALYZE story_site"); ?> Previous Comments: [2003-06-13 09:07:32] [EMAIL PROTECTED] Please provide a short but _complete_ stand-alone script. [2003-06-13 08:55:57] justinlong at strategicnetwork dot org Description: Have a 50,000 record Postgres database of articles that this code is attempting to process. CGI PHP program takes the HTML file and massages it into a non-HTML subset. Occasional segmentation faults after long runs, and sometimes the following error in the middle of a run: ll [Fri Jun 13 09:34:23 2003] Script: './article-preprocess.php' --- /usr/local/src/php-4.3.2/ext/standard/string.c(3521) : Block 0x084C9780 status: Beginning: OK (allocated on /usr/local/src/php-4.3.2/ext/standard/string.c:3330, 1024 bytes) End: Overflown (magic=0x2A8FCC33 instead of 0x2A8FCC84) 1 byte(s) overflown --- 51613 Friday, June 6: Back in Court /usr/local/src/php-4.3.2/ext/standard/string.c(3330) : Freeing 0x084C97A4 (1024 bytes), script=./article-preprocess.php Configure line: ./configure --with-pgsql=/usr2/local/pgsql --with-curl=/usr/bin,/usr/shared --with-config-file=/etc --enable-s