php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4734 return $var causes seg fault
Submitted: 2000-05-31 19:22 UTC Modified: 2000-08-27 17:45 UTC
From: john at vbulletin dot com Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 4.0.0 Release OS: Linux
Private report: No CVE-ID: None
 [2000-05-31 19:22 UTC] john at vbulletin dot com
PHP Info output:

PHP Version 4.0.0

System Linux area51.site5.com 2.2.14-5.0smp #1 SMP Tue Mar 7 21:01:40 EST 2000 i686 unknown
Build Date May 22 2000
Configure Command './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--with-mysql' '--enable-track-vars'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/lib
ZEND_DEBUG enabled
Thread Safety disabled

This program makes use of the Zend scripting language engine:
Zend Engine v1.00, Copyright (c) 1998-2000 Zend Technologies

(The same was happening with PHP4 RC2)


A certain script on this site51 host is causing seg faults. I have narrowed it down to the str_replace function I think.

Here is the result of the Apache error log:

FATAL:  emalloc():  Unable to allocate 1515870815 bytes
[Sun May 21 19:18:38 2000] [notice] child pid 16531 exit signal Segmentation
fault (11)

This is one of the various calls that creates the error:

  if ($allowsmilie==1 and $dosmilies==1) {
    $smilies=$DB_site->query("SELECT smilietext,smiliepath FROM smilie");
    while ($smilie=$DB_site->fetch_array($smilies)) {
      if ($smilie[smilietext]!="") {
        $bbcode=str_replace($smilie[smilietext],"<img
src=\"$smilie[smiliepath]\">",$bbcode);
      }
    }
  }


Commenting out the str_replace line removes the problem. This call is part of a larger script ( http://www.vbulletin.com/ ), which works fine on every
other server that it has been tested on. Indeed, this script works fine on other site51 sites too. It seems to be dependent on which database is being used. Lets say that there are 2 sites, A and B, and 2 MySQL databases C and
D.

Database D works with the PHP code from either site A or site B. Database C however, does not work from site A (untested on site B). It seems strange, since both databases were installed from the same script.

[Update!!]

Well I gave up on the backtrace in the end - the site5 support guy just ignored me.

I spent some more time on the problem and narrowed it down to the return statement in the end. The original code was like this:

function bbcodeparse ($bbcode) {

  // do some stuff with $bbcode including many str_replace and eregi_replace

  return $bbcode;

}

It was the return that seemed to be causing the crash, so I did this as a
workaround:

function bbcodeparse ($bbcode) {

  bbcodeparse2($bbcode;

  return $bbcode2;

}

function bbcodeparse2 ($bbcode) {

  global $bbcode2;

  // do stuff on $bbcode

  $bbcode2=$bbcode;

}

And that fixed the problem! I have no idea what caused it, but I got it working. :)

I can provide a copy of the scripts for anyone on the PHP team wanting to look to diagnose the problem. Just email me:
john@vbulletin.com

Thanks!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-08 22:29 UTC] waldschrott@php.net
Please verify that it?s still happening using the latest version of PHP (release 4.0.1pl2 or CVS).
 [2000-08-20 01:57 UTC] sniper@php.net
No feedback from user.

--Jani
 [2000-08-20 06:32 UTC] john at vbulletin dot com
I will try to contact the sysadmin at site5 to see if I can still reproduce the problem.

Apologies for the lack of response - I was away, and someone else was handling my email.
 [2000-08-27 17:45 UTC] sniper@php.net
No feedback and I can not reproduce this with latest CVS.

--Jani
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 11:00:01 2026 UTC