ereg_replace hangs script execution

ereg_replace hangs script execution

am 16.08.2007 20:01:46 von Shive

Hello

I'm currently working on a very old and strange script written by
someone else.

The script has to generate a document list (very long, resulting HTML
>1MB), but instead of showing the page, it hangs after a while - my
browser shows a window asking me if I want do download the file (the php
one), but it's zero bytes in size. There are no error/warning messages.

I looked into the script and noticed, that it invokes ereg_replace in a
very long loop (one invocation for each document - there are hundreds of
them). I commented out ereg_replace and it seems OK - HTML file is being
generated BUT it loses some functionality.

Why multiple ereg_* invocation makes PHP crash? Shouldn't it execute for
a long time, but yet execute? Are there any system limits involved
(memory_limit=64M - seems OK, execution_time unlimited)? May the
ereg_replace function cause an overflow-of-something and I don't know
about the bug?

My PHP ver. is 4.3.10-21.

Thanks in advance for any help.

--
shive

Re: ereg_replace hangs script execution

am 16.08.2007 20:36:04 von pakalk

On Aug 16, 8:01 pm, Shive wrote:
> Hello
>
> I'm currently working on a very old and strange script written by
> someone else.
>
> The script has to generate a document list (very long, resulting HTML
> >1MB), but instead of showing the page, it hangs after a while - my
> browser shows a window asking me if I want do download the file (the php
> one), but it's zero bytes in size. There are no error/warning messages.
>
> I looked into the script and noticed, that it invokes ereg_replace in a
> very long loop (one invocation for each document - there are hundreds of
> them). I commented out ereg_replace and it seems OK - HTML file is being
> generated BUT it loses some functionality.
>
> Why multiple ereg_* invocation makes PHP crash? Shouldn't it execute for
> a long time, but yet execute? Are there any system limits involved
> (memory_limit=64M - seems OK, execution_time unlimited)? May the
> ereg_replace function cause an overflow-of-something and I don't know
> about the bug?
>
> My PHP ver. is 4.3.10-21.
>
> Thanks in advance for any help.
>
> --
> shive

Maybe try to use preg_*() instead of ereg_*()? I think it could be the
fastest way to solve your problem ;) If it's not, you will know, that
it is not ereg funcion() bug, but somethinng in this script is not ok.

Re: ereg_replace hangs script execution

am 16.08.2007 20:38:29 von Shive

pakalk napisa³(a):
> Maybe try to use preg_*() instead of ereg_*()? I think it could be the
> fastest way to solve your problem ;) If it's not, you will know, that
> it is not ereg funcion() bug, but somethinng in this script is not ok.

Yep, I'm not so dumb and already tried that :)

I know that something in this script is not OK, but it's all I know. The
only information I have is about that ereg_replace must be commented out
for the script to run.

--
shive

Re: ereg_replace hangs script execution

am 16.08.2007 22:00:28 von pakalk

On Aug 16, 8:38 pm, Shive wrote:
> Yep, I'm not so dumb and already tried that :)

Didn't mean that.

So you have tested it with preg, and error still occurs?

> I know that something in this script is not OK, but it's all I know. The
> only information I have is about that ereg_replace must be commented out
> for the script to run.

It is hard to say what is wrong with the script if you cannot see
it ;) Maybe there is some variable name conflict, or the string is
encoded in some strange way (unacceptable for ereg and preg).

Re: ereg_replace hangs script execution

am 17.08.2007 09:27:32 von Shive

pakalk napisa³(a):
> So you have tested it with preg, and error still occurs?

Yep.

> It is hard to say what is wrong with the script if you cannot see
> it ;) Maybe there is some variable name conflict, or the string is
> encoded in some strange way (unacceptable for ereg and preg).

Maybe it is... but shouldn't ereg/preg throw an error in that case?

OK, one more observation: *maybe* it all depends on system's overall
load. Have checked it it the midnight and everything's OK even with ereg...

Yes, I know I didn't really give any precise description or diagnosis...
but I'm also blind in the dark.

--
shive

Re: ereg_replace hangs script execution

am 17.08.2007 19:34:04 von Jerry Stuckle

Shive wrote:
> pakalk napisa³(a):
>> So you have tested it with preg, and error still occurs?
>
> Yep.
>
>> It is hard to say what is wrong with the script if you cannot see
>> it ;) Maybe there is some variable name conflict, or the string is
>> encoded in some strange way (unacceptable for ereg and preg).
>
> Maybe it is... but shouldn't ereg/preg throw an error in that case?
>
> OK, one more observation: *maybe* it all depends on system's overall
> load. Have checked it it the midnight and everything's OK even with ereg...
>
> Yes, I know I didn't really give any precise description or diagnosis...
> but I'm also blind in the dark.
>

Maybe the script is timing out? Or using too much memory?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================