#29431 [Opn->Csd]: segfault using stream_* with UDP

From: Date: Sat, 31 Jul 2004 11:43:02 +0000
Subject: #29431 [Opn->Csd]: segfault using stream_* with UDP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63839@lists.php.net to get a copy of this message
ID: 29431 Updated by: wez@php.net Reported By: nlopess@php.net -Status: Open +Status: Closed Bug Type: Network related Operating System: Linux 2.4 PHP Version: 5.1.0-cvs New Comment: Nope, not a PHP; that indicates that inet_ntoa has a memory leak. However: man inet_ntoa --> The inet_ntoa() function converts the Internet host address in given in network byte order to a string in standard numbers-and-dots notation. The string is returned in a statically allocated buffer, which subsequent calls will overwrite. It's not PHP's responsibility to clean that up, and most likely it's something that valgrind should suppress anyway, and its only 18 bytes ;-) Previous Comments: ------------------------------------------------------------------------ [2004-07-31 13:16:20] nlopess@php.net The problem is fixed! Thanks!!! But valgrind still complains... Not sure if it's related with streams, but: ==14229== 18 bytes in 1 blocks are still reachable in loss record 1 of 3 ==14229== at 0x40026BB2: malloc (vg_replace_malloc.c:153) ==14229== by 0x4058638B: inet_ntoa (in /lib/libc-2.3.3.so) ==14229== by 0x81BE8BE: php_network_populate_name_from_sockaddr (network.c:593) ==14229== by 0x81CA06C: php_sockop_set_option (xp_socket.c:223) ==14229== by 0x81C27BB: _php_stream_set_option (streams.c:1110) ==14229== by 0x81C988A: php_stream_xport_recvfrom (transports.c:433) ==14229== by 0x81A4FED: zif_stream_socket_recvfrom (streamsfuncs.c:328) ==14229== by 0x8209810: zend_do_fcall_common_helper (zend_execute.c:2699) ==14229== by 0x82099FE: zend_do_fcall_handler (zend_execute.c:2831) ==14229== by 0x8205FF7: execute (zend_execute.c:1391) ==14229== by 0x81E9D59: zend_execute_scripts (zend.c:1068) ==14229== by 0x81B443F: php_execute_script (main.c:1631) ==14229== by 0x821118F: main (php_cli.c:943) ==14229== by 0x404E1858: __libc_start_main (in /lib/libc-2.3.3.so) ==14229== by 0x8080550: (within /usr/local/bin/php) ==14229== ==14229== ==14229== 100 bytes in 1 blocks are still reachable in loss record 2 of 3 ==14229== at 0x40026BB2: malloc (vg_replace_malloc.c:153) ==14229== by 0x81D353B: yy_flex_alloc (zend_language_scanner.c:6260) ==14229== by 0x81D33DB: yy_push_state (zend_language_scanner.c:6149) ==14229== by 0x81D0B02: lex_scan (zend_language_scanner.l:1152) ==14229== by 0x81DDE90: zendlex (zend_compile.c:3682) ==14229== by 0x81CEE8C: zendparse (zend_language_parser.c:2632) ==14229== by 0x81CF2F2: compile_file (zend_language_scanner.l:375) ==14229== by 0x81E9D21: zend_execute_scripts (zend.c:1064) ==14229== by 0x81B443F: php_execute_script (main.c:1631) ==14229== by 0x821118F: main (php_cli.c:943) ==14229== by 0x404E1858: __libc_start_main (in /lib/libc-2.3.3.so) ==14229== by 0x8080550: (within /usr/local/bin/php) ------------------------------------------------------------------------ [2004-07-31 13:03:55] wez@php.net Looks like I forgot to commit some changes; should be fixed now in both HEAD and 5.0 branches. ------------------------------------------------------------------------ [2004-07-31 12:25:34] nlopess@php.net # strace -e trace=network php udp.php socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address family not supported by protocol) socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(3, {sa_family=AF_INET, sin_port=htons(1113), sin_addr=inet_addr("127.0.0.1")}, 16) = 0 recv(3, "x", 8192, 0) = 1 xsendto(3, "Sat Jul 31 10:34:20 2004\r\n", 26, 0, {sa_family=0x3032 /* AF_??? */ , sa_data="04\0\0\0\0\24\325\377\277\2568)@"}, 0) = -1 EINVAL (Invalid argument) Warning: stream_socket_sendto() [/manual/function.stream-socket-sendto.html]: In valid argument in /transfer/udp.php on line 10 It just outputs 'x', so $peer is empty. ------------------------------------------------------------------------ [2004-07-31 12:06:23] wez@php.net Please try the script I posted. Paste it's output. If it doesn't work, run it using: strace -e trace=net php udp.php and paste that output too. ------------------------------------------------------------------------ [2004-07-30 21:05:49] nlopess@php.net Yep! I've done a cvsclean (and a cvs update) and re-compiled everything, and still get the same backtrace/error. ------------------------------------------------------------------------ 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/29431 -- Edit this bug report at http://bugs.php.net/?id=29431&edit=1

« previous php.bugs (#63839) next »