From:             yoarvi at gmail dot com
Operating system: Solaris 10 (SPARC)
PHP version:      6SVN-2009-11-16 (SVN)
PHP Bug Type:     Unicode Function Upgrades related
Bug description:  [PATCH] - unicode byte order difference between SPARC and x86

Description:
------------
zspprintf() incorrectly represents strings/chars as unicode characters on
Solaris (SPARC).

There are byte ordering differences for unicode representations between
x86 and SPARC:

For example, the unicode representation (i've grouped them in sets of
2chars) of '/tmp' on x86 is
'/''\0' 't''\0' 'm''\0' 'p''\0'

and on SPARC it is
'\0''/' '\0''t' '\0''m' '\0''p'

http://marc.info/?l=php-internals&m=125811990106419&w=2 has some more
details.

the problem seems to be in the smart_str_append2c macro that
zspprintf()/xbuf_format_converter end up using.

The following patch fixes the problem:
Index: ext/standard/php_smart_str.h
===================================================================
--- ext/standard/php_smart_str.h        (revision 290471)
+++ ext/standard/php_smart_str.h        (working copy)
@@ -86,10 +86,17 @@
        smart_str_appendc_ex((dest), (c), 0)

 /* appending of a single UTF-16 code unit (2 byte)*/
+#if (defined(i386) || defined(__i386__) || defined(_X86_))
 #define smart_str_append2c(dest, c) do {       \
        smart_str_appendc_ex((dest), (c&0xFF), 0);      \
        smart_str_appendc_ex((dest), (c&0xFF00 ? c>>8 : '\0'), 0);      \
 } while (0)
+#else
+#define smart_str_append2c(dest, c) do {       \
+       smart_str_appendc_ex((dest), (c&0xFF00 ? c>>8 : '\0'), 0);      \
+       smart_str_appendc_ex((dest), (c&0xFF), 0);      \
+} while (0)
+#endif

 #define smart_str_free(s) \
        smart_str_free_ex((s), 0)



Reproduce code:
---------------
% sapi/cli/php ext/spl/tests/DirectoryIterator_getBasename_basic_test.php

Expected result:
----------------
getBasename_test

Actual result:
--------------
php goes into an infinite loop

-- 
Edit bug report at http://bugs.php.net/?id=50189&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50189&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50189&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50189&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50189&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50189&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50189&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50189&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50189&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50189&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50189&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50189&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50189&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50189&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50189&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50189&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50189&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50189&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50189&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50189&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50189&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50189&r=mysqlcfg

Reply via email to