From:             [EMAIL PROTECTED]
Operating system: RedHat Linux7.0.1/ja
PHP version:      4.0.4pl1
PHP Bug Type:     Scripting Engine problem
Bug description:  Problem with muiti-byte char code set (serious)

PHP4.0.4pl1 possibly has unsafe code for 8 bit char codesets. If it is the case, any 
user, that uses charactor code from 128 to 255, may experience strange/unexpected PHP 
behavior. (Another possiblity is bugs in glibc....)

NOTE: It is very difficult to determine in what condtion program does wrong. When 
condition meets PHP does following behavior ALWAYS. (I don't figure out exact 
condition yet. i.e. what combination/location of multi-byte charset causes this 
behavior.) In most cases, I don't have this kind of problem at all. Therefore, I can't 
reproduce this problem with simple script, so I don't put them in here.

Anyway, it seems PHP4.0.4pl1 does this:

PHP4 behavior: Script is executed TWICE and included file is not processed
1) PHP parse script and start executing.
   - My script check username data in db, if there is the same username, return error. 
If not, insert new username into db.
2) PHP calls function to register new user.
2) PHP execute code to insert data into db in the function. if user can be added. PHP 
possibly encounters 8bit char unclean code some where near include()and RESTART script 
execution from the beginning.
   - The script written to include() HTML file for successful user registration.

PHP inserts new username into db at 1st execution, then it finds the same username in 
db and return error for 2nd execution. 
If I put die('died here') BEFORE include(), PHP stops execution and outputs 'died 
here'. but not AFTER include(). PHP does not stop execution inside of included file, 
too. 
I was using 'ob_gzhandler', disabling it does not make any difference.

This happened when user registration check/insert was done in function defined in 
other included file that included at the top of script. 
PHP does not log any errors when this happens. (E_ALL)

PHP4 behavior: Script does not process included file and outputs default HTML as if I 
didn't print any outputs.
(It is rewrite for the code I explained)
1) PHP parse script and start executing.
 - This script does not use function calls in contrast to previous one.
2) PHP possibly encounters 8bit char unclean code some where near include(), and 
outputs default HTML for null output and stops execution.

Therefore, I can see output from die('died here') if I put BEFORE include(), but not 
AFTER include(). If I put die('died here') inside of included file, PHP does not die 
also. 

This happened when user registration check/insert was done in the script w/o using 
functions. i.e. I'm not using functions defined included file. The script logic is 
identical to first one except it is not using any functions. 
PHP does not log any errors. (E_ALL)

When I tested with PLAIN ASCII HTML for included file. PHP WORKS as expected. i.e. It 
show html file, and die/exit from script. (before/inside/after include())

I use EUC (Extended Unix Code), EUC-JP to be specific,  for char code, which is 
supposed to work well with 8 bit char code clean programs.

[Environment]
OS: RadHat Linux7.0.1/ja(i386) FTP version (no glibc update)
Apache: Apache 1.3.17 w/ mod_ssl-2.8.0, mod_gzip-1.13.17a. build from source 
PHP: PHP4.0.4pl1 w/ pgsql-7.0.3, gd-1.8.3, mhash, mcript and others. build from 
source. (no debug option)
 - ECU-JP for all html,  php scripts
PHP Configure:
'./configure' '--with-apxs' '--disable-short-tags' '--enable-bcmath' '--with-zlib-dir' 
'--enable-ftp' '--with-imap' '--with-mhash' '--with-mcrypt' '--with-pgsql' 
'--with-swf' '--enable-sysvsem' '--enable-sysvshm' '--with-zlib' '--enable-iconv' 
'--with-kakasi' '--enable-jstring' '--enable-mbregex' '--with-namazu' 
'--with-gd=../gd-1.8.3/' '--with-jpeg-dir=/usr' '--with-xpm-dir=/usr/X11R6'

I cannot think of any reasonable explanation for this strange PHP4 behavior other than 
possibility that glibc has bugs. (8 bit char unsafe code, etc. I haven't research 
about my exact glibc version nor bugs yet, so far I don't have any problem other than 
PHP4.)

PS: I don't use EUC for var/function names, of course. I only use EUC in HTML or var 
contents. 
I really want this problem to be fixed. If you need to contact me, please do so. I'll 
try the best I can do.

Regards,
--
Yasuo Ohgaki


-- 
Edit Bug report at: http://bugs.php.net/?id=9365&edit=1



-- 
PHP Development 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]

Reply via email to