#27176 [NEW]: str_replace tries to use obscene amounts of ram

2004-02-07 Thread gaz at fission dot org dot uk
From: gaz at fission dot org dot uk
Operating system: Slackware 9.1 Linux 2.6.1 kernel
PHP version:  5.0.0b3 (beta3)
PHP Bug Type: Performance problem
Bug description:  str_replace tries to use obscene amounts of ram

Description:

When str_replace is called with the 'mixed replace' value set to a string
with a large (eg, 16,000) characters in it, it suddenly tries to asign an
absolutly obscene amount of memory.

Reproduce code:
---
/* In the code that initially showed this up, $somefile was a 20kb html
file, and $replacefile was a 6kb html file */

$input_text = file_get_contents($somefile);
$replace = file_get_contents($replacefile);
$match = __RECENT__;

$output = str_replace($match,$replce,$input_text);

Actual result:
--
The actual code tries to allocate about 34MB of memory to do this
str_replace. I think it keeps trying to reorder the char[] array, and so a
large replacement string ties it up for a while. Changing to use explode()
and foreach() tends to do the same thing but in no time, and without the
huge memory tie-up.

-- 
Edit bug report at http://bugs.php.net/?id=27176edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27176r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27176r=trysnapshot5
Fixed in CVS:   http://bugs.php.net/fix.php?id=27176r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=27176r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27176r=needtrace
Need Reproduce Script:  http://bugs.php.net/fix.php?id=27176r=needscript
Try newer version:  http://bugs.php.net/fix.php?id=27176r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=27176r=support
Expected behavior:  http://bugs.php.net/fix.php?id=27176r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=27176r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=27176r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=27176r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27176r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=27176r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=27176r=isapi
Install GNU Sed:http://bugs.php.net/fix.php?id=27176r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27176r=float


#25604 [NEW]: configure fails to define variables for use with snmp module

2003-09-19 Thread gaz at fission dot org dot uk
From: gaz at fission dot org dot uk
Operating system: Debian GNU/Linux unstable(sid)
PHP version:  4.3.3
PHP Bug Type: SNMP related
Bug description:  configure fails to define variables for use with snmp module

Description:

This may very well be a debian specific bug, I couldn't honestly say.

However, when I run:
phpize
./configure
make
make install
on the snmp library to run as a dynamic module then it compiles fine - but
config.h defines the values for HAVE_SNMP_PARSE_OID as undefined when
infact the relevant header files are installed. This means that doing an
snmpwalk(host,community,$OID) will just keep running and eventually
timeout. This seems to happen no matter what $OID is, aside from system
- it works fine like that.

Reproduce code:
---
// note, this was testing again a 3com superstack3 switch

$a = snmpwalk($host, $community, ifDescr);

print_r($a);

Expected result:

(
[0] = STRING: RMON Port 01 on unit 1
[1] = STRING: RMON Port 02 on unit 1
[2] = STRING: RMON Port 03 on unit 1
[3] = STRING: RMON Port 04 on unit 1
[4] = STRING: RMON Port 05 on unit 1
[5] = STRING: RMON Port 06 on unit 1
[6] = STRING: RMON Port 07 on unit 1
[7] = STRING: RMON Port 08 on unit 1
[8] = STRING: RMON Port 09 on unit 1
[9] = STRING: RMON Port 10 on unit 1
[10] = STRING: RMON Port 11 on unit 1
[11] = STRING: RMON Port 12 on unit 1
[12] = STRING: RMON Port 13 on unit 1
[13] = STRING: RMON Port 14 on unit 1
[14] = STRING: RMON Port 15 on unit 1
[15] = STRING: RMON Port 16 on unit 1
[16] = STRING: RMON Port 17 on unit 1
[17] = STRING: RMON Port 18 on unit 1
[18] = STRING: RMON Port 19 on unit 1
[19] = STRING: RMON Port 20 on unit 1
[20] = STRING: RMON Port 21 on unit 1
[21] = STRING: RMON Port 22 on unit 1
[22] = STRING: RMON Port 23 on unit 1
[23] = STRING: RMON Port 24 on unit 1
[24] = STRING: RMON Port 25 on unit 1
[25] = STRING: RMON Port 26 on unit 1
[26] = STRING: Console Port 192.168.101.1   on unit 1
[27] = STRING: Management Port 195.74.109.38   on unit 1
[28] = STRING: VLAN 1
[29] = STRING: 802.1Q Encapsulation Tag 0001
[30] = STRING: Stack Aggregated Link 01
[31] = STRING: Stack Aggregated Link 02
[32] = STRING: Stack Aggregated Link 03
[33] = STRING: Stack Aggregated Link 04
)


Actual result:
--
I just get a timeout

-- 
Edit bug report at http://bugs.php.net/?id=25604edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25604r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25604r=trysnapshot5
Fixed in CVS:   http://bugs.php.net/fix.php?id=25604r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=25604r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25604r=needtrace
Try newer version:  http://bugs.php.net/fix.php?id=25604r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=25604r=support
Expected behavior:  http://bugs.php.net/fix.php?id=25604r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=25604r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=25604r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=25604r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25604r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=25604r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=25604r=isapi
Install GNU Sed:http://bugs.php.net/fix.php?id=25604r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25604r=float