From:             [EMAIL PROTECTED]
Operating system: FreeBSD 4.0
PHP version:      4.0.4
PHP Bug Type:     Sockets related
Bug description:  read() on udp-sockets fails

<?
    $port=7;
    $ip="127.0.0.1";
    $sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
    $retval=connect($sock,$ip,$port);

    write($sock,"blaat\n",6);

    $numread=read($sock,&$readdata,1);
    printf("%d %02x %s\n",$numread,ord($readdata),$readdata);

    close($sock);
?>

When changing the 1 on read() to a different number, or when calling it multiple 
times, the read() function hangs due to an unknown reason (at least for me). This 
example tries to read from the echo-service, I encountered the problem when developing 
a radius-client in PHP.

This is the stack of the process:
#0  0x2825b794 in read () from /usr/lib/libc.so.4
#1  0x809dd78 in php_read (fd=4, buf=0x81e512c, maxlen=2) at sockets.c:640
#2  0x809df38 in php_if_read (ht=3, return_value=0x821768c, this_ptr=0x0,
    return_value_used=1) at sockets.c:692
#3  0x81121bc in execute (op_array=0x820948c) at ./zend_execute.c:1519
#4  0x80ea45b in zend_execute_scripts (type=8, file_count=3) at zend.c:729
#5  0x807c360 in php_execute_script (primary_file=0xbfbff408) at main.c:1221
#6  0x80f5eda in apache_php_module_main (r=0x821b034, display_source_mode=0)
    at sapi_apache.c:89
#7  0x8079cda in send_php ()
#8  0x8079d12 in send_parsed_php ()
#9  0x811c7f5 in ap_invoke_handler ()
#10 0x8130850 in process_request_internal ()
#11 0x81308ba in ap_process_request ()
#12 0x8127b2b in child_main ()
#13 0x8127db0 in make_child ()
#14 0x8128134 in perform_idle_server_maintenance ()
#15 0x8128659 in standalone_main ()
#16 0x8128c88 in main ()
#17 0x8062801 in _start ()

and info on the first two frames:
(gdb) up
#1  0x809dd78 in php_read (fd=4, buf=0x81e512c, maxlen=2) at sockets.c:640
640                       m = read(fd, (void *) t, 1);

(gdb) info locals
t = 0x81e512d "laat"
m = 1
n = 1
no_read = 1
nonblock = 0

(gdb) up
#2  0x809df38 in php_if_read (ht=3, return_value=0x821768c, this_ptr=0x0,
    return_value_used=1) at sockets.c:692

(gdb) info locals
ht = 136204588
return_value = (zval *) 0x821768c
fd = (zval **) 0x8216c0c
buf = (zval **) 0x8216c10
length = (zval **) 0x8216c14
binary = (zval **) 0x78b740
tmpbuf = 0x81e512c "blaat"
ret = 134864068
read_function = (int (*)()) 0x809dcc4 <php_read>
 
configure is ran with:
Configure Command './configure' '--with-apache=../apache_1.3.12' '--enable-track-vars' 
'--with-ndbm' '--with-db' '--with-mysql' '--enable-sockets'

If you need more information, feel free to ask me.

Edwin



-- 
Edit Bug report at: http://bugs.php.net/?id=8761&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