#20703 [NEW]: session object's array is restored corruptly

2002-11-28 Thread khayll
From: [EMAIL PROTECTED]
Operating system: debian woody latest
PHP version:  4.2.2
PHP Bug Type: Class/Object related
Bug description:  session object's array is restored corruptly

I'am not sure, if this is a in bug php, could be in my code, but I have
looked my code over and over and could not find anything...

So I describe my problem:

I have a session object, and it has an array variable.
In the code I do some array_shift, and array_push on one of the elements
of this array, wich is also an array. And I do something like this:

"get" return by reference from the session objects array:
$keyArray=&$object->get("key");

then I do array_shift, and array_push to maintain a FIFO like thing to
store the previous pagenames.

Now the problem:

normally this works in a number of pages, but in case of one page it acts
strangely: for some reason an extra element into the array appears like
this:

normally the array values should change when going from page5 to page6

from (now I am on page5):

page1
page2
page3
page4
page5

into (here there is a request for a new page: page6):

page2
page3
page4
page5
page6

but instead !!! it changes to:

page1
page5
page1
page6
page1


I tried to track down where this happens, and I found out, that is
happening between the __sleep and __wakeup methods, which would mean, that
serialize, and unserialize does not work correctly.

Another wery strange thing is that this work perfecly on the local
development server, which runs the same version of php...


so that's it... I am going mad now! bye..
-- 
Edit bug report at http://bugs.php.net/?id=20703&edit=1
-- 
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20703&r=trysnapshot
Fixed in CVS:   http://bugs.php.net/fix.php?id=20703&r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=20703&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20703&r=needtrace
Try newer version:  http://bugs.php.net/fix.php?id=20703&r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=20703&r=support
Expected behavior:  http://bugs.php.net/fix.php?id=20703&r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=20703&r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=20703&r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=20703&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20703&r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=20703&r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=20703&r=isapi




#34851 [NEW]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
From: khayll at motoros dot hu
Operating system: win 2k3 server
PHP version:  4.4.0
PHP Bug Type: Sockets related
Bug description:  SO_RECVTIMEO sec stands for usec and usec has no effect!

Description:

I tried to set a receive timeout for a socket, but found out that sec is
used as usec, and usec is in fact ignored!


Reproduce code:
---
using a modbus device  with "address" address, sorry i cannot make it
available on the net

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>0,
"usec"=>500));
socket_connect($socket, "address", "502");
socket_write($this->socket, $data, strlen($data));
socket_read($this->socket, 512, PHP_BINARY_READ);



Expected result:

expected to read some data or give a timeout error.


Actual result:
--
code hangs, so i figured out, that usec has no effect, then i tried 1 sec
as timeout, code began to work, but kept reporting timeout, so i figured
out if i try a value like 50 as sec it works. Seems like sec is used
as usec, and usec has no effect.


-- 
Edit bug report at http://bugs.php.net/?id=34851&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34851&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34851&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34851&r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=34851&r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=34851&r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=34851&r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=34851&r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=34851&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34851&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=34851&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=34851&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=34851&r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=34851&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34851&r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=34851&r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=34851&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34851&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34851&r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=34851&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34851&r=mysqlcfg


#34851 [Fbk->Opn]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
 ID:   34851
 User updated by:  khayll at motoros dot hu
 Reported By:  khayll at motoros dot hu
-Status:   Feedback
+Status:   Open
 Bug Type: Sockets related
 Operating System: win 2k3 server
 PHP Version:  4.4.0
 New Comment:

5,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>


Previous Comments:


[2005-10-13 12:31:30] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



----

[2005-10-13 11:38:15] khayll at motoros dot hu

Description:

I tried to set a receive timeout for a socket, but found out that sec
is used as usec, and usec is in fact ignored!


Reproduce code:
---
using a modbus device  with "address" address, sorry i cannot make it
available on the net

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>0,
"usec"=>500));
socket_connect($socket, "address", "502");
socket_write($this->socket, $data, strlen($data));
socket_read($this->socket, 512, PHP_BINARY_READ);



Expected result:

expected to read some data or give a timeout error.


Actual result:
--
code hangs, so i figured out, that usec has no effect, then i tried 1
sec as timeout, code began to work, but kept reporting timeout, so i
figured out if i try a value like 50 as sec it works. Seems like
sec is used as usec, and usec has no effect.






-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1


#34851 [Fbk->Opn]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
 ID:   34851
 User updated by:  khayll at motoros dot hu
 Reported By:  khayll at motoros dot hu
-Status:   Feedback
+Status:   Open
 Bug Type: Sockets related
 Operating System: win 2k3 server
 PHP Version:  4.4.0
 New Comment:

Actual: Script gives timeout error but it does not wait for 5 seconds
for the answer, as set in SO_RCVTIMEO.

Expeted: to wait max. 5 second for remote host to answer, but script
executes much faster. I tried to increase second to 50 and then it
works ok.


Previous Comments:


[2005-10-13 16:16:23] [EMAIL PROTECTED]

And actual/expected results please?



[2005-10-13 14:36:01] khayll at motoros dot hu

5,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>



[2005-10-13 12:31:30] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



----

[2005-10-13 11:38:15] khayll at motoros dot hu

Description:

I tried to set a receive timeout for a socket, but found out that sec
is used as usec, and usec is in fact ignored!


Reproduce code:
---
using a modbus device  with "address" address, sorry i cannot make it
available on the net

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>0,
"usec"=>500));
socket_connect($socket, "address", "502");
socket_write($this->socket, $data, strlen($data));
socket_read($this->socket, 512, PHP_BINARY_READ);



Expected result:

expected to read some data or give a timeout error.


Actual result:
--
code hangs, so i figured out, that usec has no effect, then i tried 1
sec as timeout, code began to work, but kept reporting timeout, so i
figured out if i try a value like 50 as sec it works. Seems like
sec is used as usec, and usec has no effect.






-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1


#34851 [Opn]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
 ID:   34851
 User updated by:  khayll at motoros dot hu
 Reported By:  khayll at motoros dot hu
 Status:   Open
 Bug Type: Sockets related
 Operating System: win 2k3 server
 PHP Version:  4.4.0
 New Comment:

And if I set sec=0 usec=50 (or 5 for a shorter timeout) it hangs,
meaning to me, that usec has no effect.


Previous Comments:


[2005-10-13 17:38:56] khayll at motoros dot hu

Actual: Script gives timeout error but it does not wait for 5 seconds
for the answer, as set in SO_RCVTIMEO.

Expeted: to wait max. 5 second for remote host to answer, but script
executes much faster. I tried to increase second to 50 and then it
works ok.



[2005-10-13 16:16:23] [EMAIL PROTECTED]

And actual/expected results please?



[2005-10-13 14:36:01] khayll at motoros dot hu

5,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>



[2005-10-13 12:31:30] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



----

[2005-10-13 11:38:15] khayll at motoros dot hu

Description:

I tried to set a receive timeout for a socket, but found out that sec
is used as usec, and usec is in fact ignored!


Reproduce code:
---
using a modbus device  with "address" address, sorry i cannot make it
available on the net

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>0,
"usec"=>500));
socket_connect($socket, "address", "502");
socket_write($this->socket, $data, strlen($data));
socket_read($this->socket, 512, PHP_BINARY_READ);



Expected result:

expected to read some data or give a timeout error.


Actual result:
--
code hangs, so i figured out, that usec has no effect, then i tried 1
sec as timeout, code began to work, but kept reporting timeout, so i
figured out if i try a value like 50 as sec it works. Seems like
sec is used as usec, and usec has no effect.






-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1


#34851 [Opn]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
 ID:   34851
 User updated by:  khayll at motoros dot hu
 Reported By:  khayll at motoros dot hu
 Status:   Open
 Bug Type: Sockets related
 Operating System: win 2k3 server
 PHP Version:  4.4.0
 New Comment:

sorry I forgot a line from the code:

I also decreased the sec param to 1 because for me the remote host is
quite fast.

1,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

$data = $adu.$pdu;

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>


Previous Comments:
----

[2005-10-13 17:41:05] khayll at motoros dot hu

And if I set sec=0 usec=50 (or 5 for a shorter timeout) it hangs,
meaning to me, that usec has no effect.

----

[2005-10-13 17:38:56] khayll at motoros dot hu

Actual: Script gives timeout error but it does not wait for 5 seconds
for the answer, as set in SO_RCVTIMEO.

Expeted: to wait max. 5 second for remote host to answer, but script
executes much faster. I tried to increase second to 50 and then it
works ok.



[2005-10-13 16:16:23] [EMAIL PROTECTED]

And actual/expected results please?

----

[2005-10-13 14:36:01] khayll at motoros dot hu

5,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>



[2005-10-13 12:31:30] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.





The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/34851

-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1


#34851 [Fbk->Opn]: SO_RECVTIMEO sec stands for usec!!!! and usec has no effect!

2005-10-13 Thread khayll at motoros dot hu
 ID:   34851
 User updated by:  khayll at motoros dot hu
 Reported By:  khayll at motoros dot hu
-Status:   Feedback
+Status:   Open
 Bug Type: Sockets related
 Operating System: win 2k3 server
 PHP Version:  4.4.0
 New Comment:

Please read carefully what I wrote...

If I use 0 sec and 500 usec, the script HANGS when there's no response
(which means usec has NO EFFECT)! (Sorry I cannot reproduce remote
machine not sending a response, but accepting connections) and with a
setting of 1 sec 0 usec which is pretty much for a response I get a
timeout error.

here execute this script and it will show you the script execution time
is less than 1 sec at all giving a timeout:

\n";

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>1,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

$data = $adu.$pdu;

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

if($result===false) echo
socket_strerror(socket_last_error())."\n";

socket_shutdown($socket, 2);
socket_close($socket);

echo microtime()."\n";

?>

result:

0.32968200 1129220264

Warning: socket_read() unable to read from socket [0]: A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in
c:\data\web\rtu\rtu_web\phpbug.php on line 20
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond. 
0.89507800 1129220264


Previous Comments:


[2005-10-13 17:52:57] [EMAIL PROTECTED]

Well, that's because USEC are *microseconds*, not milliseconds.
Try to use sec=0 usec=500 instead.



[2005-10-13 17:52:20] khayll at motoros dot hu

sorry I forgot a line from the code:

I also decreased the sec param to 1 because for me the remote host is
quite fast.

1,
"usec"=>0));
socket_connect($socket, "81.182.13.109", "502");

$pdu = "";
$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

$rand = mt_rand(1,65535); //generate random adu id
$adu = "";
$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);

$data = $adu.$pdu;

socket_write($socket, $data, strlen($data));

$result = socket_read($socket, 512, PHP_BINARY_READ);

echo socket_strerror(socket_last_error());

socket_shutdown($socket, 2);
socket_close($socket);

?>



[2005-10-13 17:41:05] khayll at motoros dot hu

And if I set sec=0 usec=50 (or 5 for a shorter timeout) it hangs,
meaning to me, that usec has no effect.



[2005-10-13 17:38:56] khayll at motoros dot hu

Actual: Script gives timeout error but it does not wait for 5 seconds
for the answer, as set in SO_RCVTIMEO.

Expeted: to wait max. 5 second for remote host to answer, but script
executes much faster. I tried to increase second to 50 and then it
works ok.



[2005-10-13 16:16:23] [EMAIL PROTECTED]

And actual/expected results please?



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/34851

-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1