php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52077 SNMP GET/WALK may hangs FOREVER
Submitted: 2010-06-13 21:41 UTC Modified: 2013-02-18 00:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: wajim at mail dot ru Assigned:
Status: No Feedback Package: SNMP related
PHP Version: 5.2.13 OS: Win XP SP3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wajim at mail dot ru
New email:
PHP Version: OS:

 

 [2010-06-13 21:41 UTC] wajim at mail dot ru
Description:
------------
Under a heavy GET/WALK-ing (form localhost to localhost) php may hangs forever -> apache's threads becomes zombies with CLOSE_WAIT sates even all timeouts (php and apache) are elapsed many times.

Call-stack of a one zombie-thread:
ntoskrnl.exe!KiUnlockDispatcherDatabase+0x77
ntoskrnl.exe!KeSetEvent+0x74
ntoskrnl.exe!PspGetSetContextSpecialApc+0x4e
ntoskrnl.exe!KiDeliverApc+0xb3
ntoskrnl.exe!KiSwapThread+0x64
ntoskrnl.exe!KeWaitForSingleObject+0x1c2
ntoskrnl.exe!NtWaitForSingleObject+0x9a
ntoskrnl.exe!KiFastCallEntry+0xf8
ntdll.dll!KiFastSystemCallRet
ntdll.dll!ZwWaitForSingleObject+0xc
mswsock.dll!SockWaitForSingleObject+0x1a0
mswsock.dll!WSPRecvFrom+0x1f0
WS2_32.dll!recvfrom+0x89
php_snmp.dll!snmp_sess_read+0x21f
php_snmp.dll!snmp_sess_read+0x10
php_snmp.dll!snmp_read+0x17
php_snmp.dll!snmp_synch_response_cb+0xe8
php_snmp.dll!snmp_synch_response+0x19
php_snmp.dll!php_snmp_internal+0x267
php_snmp.dll!php_snmp+0x6da
php_snmp.dll!zif_snmp2_get+0x27
php5ts.dll!zend_do_fcall_common_helper_SPEC+0x7ab
php5ts.dll!ZEND_DO_FCALL_SPEC_CONST_HANDLER+0xe5
php5ts.dll!execute+0x1c5
php5ts.dll!zend_do_fcall_common_helper_SPEC+0x8ca
php5ts.dll!ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER+0x15
php5ts.dll!execute+0x1c5
php5ts.dll!zend_do_fcall_common_helper_SPEC+0x8ca
php5ts.dll!ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER+0x15
php5ts.dll!execute+0x1c5
php5ts.dll!zend_execute_scripts+0x107
php5ts.dll!php_execute_script+0x21d
php5apache.dll!apache_php_module_main+0x91
php5apache.dll!send_php+0x265
php5apache.dll!send_parsed_php+0x10
ApacheCore.dll!ap_invoke_handler+0x87
ApacheCore.dll!ap_process_request+0x2b4
ApacheCore.dll!ap_process_request+0x26
ApacheCore.dll!ap_start_restart+0x37f
WS2_32.dll!WSASocketW+0x119

IMHO bad call "WS2_32.dll!recvfrom" in buggy ucd-snmp library may hangs. There are no socket option like "setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, ..." before recvfrom call.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-19 15:03 UTC] larryjadams at comcast dot net
Stupid WINSock does not support send and receive timeout socket options.  It's a poorly implemented socket api.  The net-snmp guys will have to implement with an alarm.  It can not be solved here.  But nice catch.
 [2010-06-19 15:13 UTC] wajim at mail dot ru
static int _sess_read(void *sessp, fd_set *fdset){
[cut]
    unsigned long unblock; //WAJIM
[cut]
unblock = 1; ioctlsocket(isp->sd, FIONBIO, &unblock); //WAJIM
length = recvfrom(isp->sd, (char *)packet, PACKET_LENGTH, 0, (struct sockaddr *)&from, &fromlength);
unblock = 0; ioctlsocket(isp->sd, FIONBIO, &unblock); //WAJIM
[cut]
}

Those my 3 lines in snmp_api.c (ucd-snmp-4.2.7.1) fixes threads hanging. :-)
 [2010-06-19 15:31 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-06-19 15:31 UTC] pajoye@php.net
did you send a patch to the ucd-snmp maintainers?

If your patch is accepted I can then patch our builds, and it will be fixed for the next 5.3.x release (can't and won't touch snmp in 5.2 touch).
 [2010-06-19 15:59 UTC] wajim at mail dot ru
In net-snmp bugtracker I yet did not write.
 [2011-07-17 09:27 UTC] lytboris@php.net
Try to use up-to-date Net-SNMP library and report results. UCD-SNMP library support is dropped in PHP 5.4.
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC