[PHP] when logic fails, PHP randomly skips execution of lines

2001-09-18 Thread Jens Kisters

Hello everbody,

I have noticed something quite strange,
i have a piece of code that looks like, i removed some of it to make it
readable:

there are no statements in the code that would cause the termination of the
method before reaching the last line, no return, die or whatever.
?

  echo \nBegin\n;

/* some code that builds a string of a few hundred bytes*/

/* a loop that ads ads numbers to the ascii vals of those string named $enc
*/

/* a loop that swaps all the neighboring chars in the string */

  echo swap: .$enc.\n;

// swap 1st and 2nd half of string
  $len=strlen($enc);
  $enc=substr($enc,$len/2,$len/2).substr($enc,0,$len/2);

  echo swp2: .$enc.\n;

  echo end\n;

?

This thing is part of a object method, which is called repeatedly.

There absolutely NO way 'end' could be printed here without 'swp2' being
printed, right, but it does.
Also i have occurences of 'swap' without a matching 'end' or 'swp2', like
this:
(the garbage is the content of '$enc', removing it from the output causes
the error to dissappear)
-output-
Begin
swap:
0064277255621244332329528893584643078166114004540827;5862126663:629;888;;58
664307819;fX$reJxre|yuw%iVft$rhyuujlnnçm5wi(vkq#ch|ijfj2
.25C18U8oej|kf!py~3364e\tj||whi(goxk07;2iYximee~%vo~2y82X:nebyif#qwuvwwg
swp2: ft$rhyuujlnnçm5wi(vkq#ch|ijfj2
.25C18U8oej|kf!py~3364e\tj||whi(goxk07;2iYximee~%vo~2y82X:nebyif#qwuvwwg0064
277255621244332329528893584643078166114004540827;5862126663:629;888;;586643
07819;fX$reJxre|yuw%iV
end

Begin
swap:
0054716330009693653323102831238781328247354221531537080463:95@4734928:223572
128238\:nhig#gfM{vo#wsk
rk)qkGwvpdudkm#mgg(zmnvppemskhrgC!lxtj3F06H;xokwzj3z33N:|fi|xd7v28TBegin
swap:
0034211011257391046799446105509563315163822007167287673;775?=6991;601553
161375F8eqaoeufd!sæItp{fnynnwrruar%n~fnf1!3/6B92t2tv!keUvlio3g27k;senhQ)
omy{0e65e;brfxV%wzdv7g70i2ýrfoY%jrni
swp2:
!sæItp{fnynnwrruar%n~fnf1!3/6B92t2tv!keUvlio3g27k;senhQ)omy{0e65e;brfxV%wz
dv7g70i2ýrfoY%jrni0034211011257391046799446105509563315163822007167287673;77
5?=6991;601553161375F8eqaoeufd
end
Begin
swap:
00549629613229801512122201313670455389527981851464=:2:4997727A;:21981;306703
59349588`7mlmkvmF!pkk{lgvg}|hg%sþfpk
fhXexmeèqmf(nzc'ovJmyovzin|ukpk9B02G?qsuxtf1270gEnqwl34=5jK}f17=8vXzpmotn
swp2: pkk{lgvg}|hg%sþfpk
fhXexmeèqmf(nzc'ovJmyovzin|ukpk9B02G?qsuxtf1270gEnqwl34=5jK}f17=8vXzpmotn005
49629613229801512122201313670455389527981851464=:2:4997727A;:21981;306703593
49588`7mlmkvmF!
end
Begin
swap:
002471894193230257221322567045301134119648109371:9=16238:5:521366563457011
4;bNmtpmjlÿn5sL)rGhiMxyjeohfxgz rn#dnBueoftgvqdsnk5omTqfth
AnZjesh2#66H7erhruu#stj)z26@.9382qTwsqfkoöm5y22B6238:5:5213665634570114;bNm
tpmjlÿn5sL)rGhiMxyjeohfxgz r
end
Begin
swap:
00547198053854516883507941428066511232699173281113A7::84385:7:051640:68
192521?3I9qnyNojlm)zcxupjm%ckl(qtRhv$o*}qzu\156dYt|ujdznlpikxtx2581xPetv
n8782uLifn{0x38G=rvxmvdxg
swp2:
pjm%ckl(qtRhv$o*}qzu\156dYt|ujdznlpikxtx2581xPetvn8782uLifn{0x38G=rvxmvdxg
00547198053854516883507941428066511232699173281113A7::84385:7:051640:68
192521?3I9qnyNojlm)zcxu
end-output-
Multiple cases of malfunction in this output,
After 2nd Begin: method was not executed properly, even though script
continued afterwards.
The next Blocks seem to miss either the \n before begin or the \n after end
in the fourth block, swap and end are displayed while swp2 is not

When i start to reduce the code by either removing $enc from the output or
deleting the loops that manipulate the string before, the echos come in the
right order and ammount...

What can i do, nothing crashed so i dont have a gdb backtrace for an bug
report.
I cant provide all the code, neither can i reduce the code without the error
do disappear

The problem occured on
PHP 4.04pl1 on Apache 1.3.x on Linux
PHP 4.04 on Apache 1.3.x on Linux
PHP 4.06 on Apache 1.3.x on W2K

thanks
Jens




RE: [PHP] when logic fails, PHP randomly skips execution of lines

2001-09-18 Thread php

How about:


$enc=abcdefe;

  echo swap: .$enc.\n;

// swap 1st and 2nd half of string
  $len= (int)strlen($enc)/2;
  $enc=substr($enc,$len).substr($enc,0,$len);

  echo swp2: .$enc.\n;

  echo end\n;


Your /2 system wont' work when strlen is an odd number.

Sean

-Original Message-
From: Jens Kisters [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 19 September 2001 2:43 AM
To: [EMAIL PROTECTED]
Subject: [PHP] when logic fails, PHP randomly skips execution of lines


Hello everbody,

I have noticed something quite strange,
i have a piece of code that looks like, i removed some of it to make it
readable:

there are no statements in the code that would cause the termination of the
method before reaching the last line, no return, die or whatever.
?

  echo \nBegin\n;

/* some code that builds a string of a few hundred bytes*/

/* a loop that ads ads numbers to the ascii vals of those string named $enc
*/

/* a loop that swaps all the neighboring chars in the string */

  echo swap: .$enc.\n;

// swap 1st and 2nd half of string
  $len=strlen($enc);
  $enc=substr($enc,$len/2,$len/2).substr($enc,0,$len/2);

  echo swp2: .$enc.\n;

  echo end\n;

?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]