|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-19 13:34 UTC] dedmajor at gmail dot com
Description:
------------
#38770 not fixed(?) in 5.2.1-dev
on x86_64 AMD Opteron(tm) Processor 265 unpack don't work, on i686 Intel(R) Celeron(R) CPU 2.50GHz works fine for example.
Reproduce code:
---------------
php -r 'print_r(unpack("N", pack("N", 41445)));
Expected result:
----------------
Array
(
[1] => 41445
)
Actual result:
--------------
Array
(
[1] => -2147442203
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 21:00:01 2025 UTC |
This isn't bogus, this is a real bug that causes pain. N is there for people writing code that talks to network services that need to convert numbers from network byte order to the native format. Also note that we get a bonus crash bug on 64-bit platforms too: $fail = '\x00\x00\x00\x8c'; $result = unpack('Nsize', $fail); $size = $result['size'] & 0xffffffff; // BANG!Okay, I will say exactly where I have this problem: PHP 5.2.1 # cat /proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 15 model : 67 model name : AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ # uname -a Linux silver 2.6.18-8.1.1.el5 #1 SMP Mon Apr 9 09:43:24 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux php -r 'print_r(unpack("N", pack("N", 41445))); returns the same as metioned int the original message about this bug: -2147442203 If you use sprintf('%b',....), you can see: 1111111111111111111111111111111110000000000000001010000111100101 First 32 bits are set to 1. There is no problem on Intel Xeon 64-bit processor as I could test.