You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered an incorrect behavior while running PHP code over HHVM and fixed it. Could you review the change? If it is good to go it can be taken up by HHVM.
I am running our PHP code over HHVM. The code makes a call stream_socket_sendto(). This call does not work and the error message received is "Transport endpoint is already connected".
f_socket_sendto() in HHVM is executed for the PHP call to stream_socket_sendto()
socket type is AF_UNIX
sendto() is called and it returns EISCONN (Transport endpoint is already connected)
Debugged HHVM code and following are the details.
Back trace:
#0 HPHP::f_stream_socket_sendto (socket=..., data=..., flags=0, address=...)
at /home/zlive/dev/hiphop-php/hphp/runtime/ext/ext_stream.cpp:388
#1 0x0000000001595ad4 in HPHP::fg_stream_socket_sendto (ar=0x7fffe5dbff50)
at /home/zlive/dev/hiphop-php/hphp/runtime/ext/ext_stream.ext_hhvm.cpp:1182
#2 0x0000000000efea86 in iopNativeImpl (this=0x7fffecb51c00, numInstrs=-438567104)
at /home/zlive/dev/hiphop-php/hphp/runtime/vm/bytecode.cpp:6786
#8 0x0000000000eedc39 in HPHP::VMExecutionContext::invokeUnit (this=0x7fffecb51c00, retval=0x7fffffffd770, unit=0x7fffe6de8c00)
at /home/zlive/dev/hiphop-php/hphp/runtime/vm/bytecode.cpp:2243
#9 0x0000000000cfd2eb in HPHP::eval_invoke_file_hook (res=..., path=, once=,
variables=<value optimized out>, currentDir=<value optimized out>) at /home/zlive/dev/hiphop-php/hphp/runtime/eval/eval.cpp:57
#10 0x00000000008a3669 in HPHP::invoke_file (s=..., once=true, variables=, currentDir=)
at /home/zlive/dev/hiphop-php/hphp/hhvm/externals_stubs.cpp:47
#11 0x0000000000ba87e5 in HPHP::include_impl_invoke (file=..., once=true, variables=0x0, currentDir=0x18be538 "")
at /home/zlive/dev/hiphop-php/hphp/runtime/base/builtin_functions.cpp:1663
#12 0x0000000000bd7e1f in hphp_invoke (argc=3, argv=0x7fffffffe5a8)
at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:1365
#13 hphp_invoke_simple (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:1336 #14 HPHP::execute_program_impl (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:1101 #15 0x0000000000bd8da8 in HPHP::execute_program (argc=3, argv=0x7fffffffe5a8)
at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:713
#16 0x00000000008a26eb in main (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/hhvm/main.cpp:41
Highlighting the code portion that is executed and the error returned from f_socket_sendto():
Variant f_socket_sendto(CObjRef socket, CStrRef buf, int len, int flags,
CStrRef addr, int port /* = 0 */) {
...
switch (sock->getType()) {
...
case AF_UNIX:
retval = sendto(sock->fd(), buf, len, flags,
(struct sockaddr *)&s_un, SUN_LEN(&s_un));
}
...
}
if (retval == -1) {
SOCKET_ERROR(sock, "unable to write to socket", errno);
return false;
}
...
if (retval == -1) {
SOCKET_ERROR(sock, "unable to write to socket", errno);
return false;
}
...
}
Fix :
I looked at man page of sendto() and it says following:
...
If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET) socket, the parameters to and tolen are ignored (and the error EISCONN may be returned when they are not NULL and 0), and the error ENOTCONN is returned when the socket was not actually connected.
...
In our context, we are using SOCK_STREAM.
Keeping the last two arguments to NULL and 0 are working fine and as expected.
So the change is :
File: hphp/runtime/ext/ext_socket.cpp
769 //Ensure the clause is executed conservatively for SOCK_STREAM
770 //only and for other sockets keep the execution as before
771 retval = sendto(sock->fd(), buf, len, flags,
772 NULL, 0); //Line Added
773 //(struct sockaddr *)&s_un, SUN_LEN(&s_un)); //Line Deleted
Afterwards it is working fine for the PHP code.
I am running HHVM on CnetOS-6.2.
[]$ uname -a
Linux zlive-platform-dapi-infra-dev-hhvmdebug-03 2.6.32-220.23.1.el6.x86_64 #1 SMP Mon Jun 18 18:58:52 BST 2012 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered:
To close the loop, this is not actionable at the moment and the issue is months also so we're closing it. If someone has a working repro [it may have been fixed by now as this was months ago] or a fix for it, please let us know.
I have encountered an incorrect behavior while running PHP code over HHVM and fixed it. Could you review the change? If it is good to go it can be taken up by HHVM.
I am running our PHP code over HHVM. The code makes a call stream_socket_sendto(). This call does not work and the error message received is "Transport endpoint is already connected".
Debugged HHVM code and following are the details.
Back trace:
#0 HPHP::f_stream_socket_sendto (socket=..., data=..., flags=0, address=...)
#1 0x0000000001595ad4 in HPHP::fg_stream_socket_sendto (ar=0x7fffe5dbff50)
#2 0x0000000000efea86 in iopNativeImpl (this=0x7fffecb51c00, numInstrs=-438567104)
#3 HPHP::VMExecutionContext::dispatchImpl<0> (this=0x7fffecb51c00, numInstrs=-438567104)
#4 0x0000000000eec5af in dispatch (this=0x7fffecb51c00, enterFnAr=)
#5 HPHP::VMExecutionContext::enterVMWork (this=0x7fffecb51c00, enterFnAr=)
#6 0x0000000000eec9fe in HPHP::VMExecutionContext::enterVM (this=0x7fffecb51c00, retval=0x7fffffffd770, ar=0x7fffe5dbffc0, extraArgs=0x0)
#7 0x0000000000eed63f in HPHP::VMExecutionContext::invokeFunc (this=0x7fffecb51c00, retval=0x7fffffffd770, f=0x7fffe6337380,
#8 0x0000000000eedc39 in HPHP::VMExecutionContext::invokeUnit (this=0x7fffecb51c00, retval=0x7fffffffd770, unit=0x7fffe6de8c00)
#9 0x0000000000cfd2eb in HPHP::eval_invoke_file_hook (res=..., path=, once=,
#10 0x00000000008a3669 in HPHP::invoke_file (s=..., once=true, variables=, currentDir=)
#11 0x0000000000ba87e5 in HPHP::include_impl_invoke (file=..., once=true, variables=0x0, currentDir=0x18be538 "")
#12 0x0000000000bd7e1f in hphp_invoke (argc=3, argv=0x7fffffffe5a8)
#13 hphp_invoke_simple (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:1336
#14 HPHP::execute_program_impl (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/runtime/base/program_functions.cpp:1101
#15 0x0000000000bd8da8 in HPHP::execute_program (argc=3, argv=0x7fffffffe5a8)
#16 0x00000000008a26eb in main (argc=3, argv=0x7fffffffe5a8) at /home/zlive/dev/hiphop-php/hphp/hhvm/main.cpp:41
Highlighting the code portion that is executed and the error returned from f_socket_sendto():
Variant f_socket_sendto(CObjRef socket, CStrRef buf, int len, int flags,
CStrRef addr, int port /* = 0 */) {
...
switch (sock->getType()) {
...
case AF_UNIX:
retval = sendto(sock->fd(), buf, len, flags,
(struct sockaddr *)&s_un, SUN_LEN(&s_un));
}
...
}
if (retval == -1) {
SOCKET_ERROR(sock, "unable to write to socket", errno);
return false;
}
...
if (retval == -1) {
SOCKET_ERROR(sock, "unable to write to socket", errno);
return false;
}
...
}
Fix :
I looked at man page of sendto() and it says following:
...
If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET) socket, the parameters to and tolen are ignored (and the error EISCONN may be returned when they are not NULL and 0), and the error ENOTCONN is returned when the socket was not actually connected.
...
In our context, we are using SOCK_STREAM.
Keeping the last two arguments to NULL and 0 are working fine and as expected.
So the change is :
File: hphp/runtime/ext/ext_socket.cpp
769 //Ensure the clause is executed conservatively for SOCK_STREAM
770 //only and for other sockets keep the execution as before
771 retval = sendto(sock->fd(), buf, len, flags,
772 NULL, 0); //Line Added
773 //(struct sockaddr *)&s_un, SUN_LEN(&s_un)); //Line Deleted
Afterwards it is working fine for the PHP code.
I am running HHVM on CnetOS-6.2.
[]$ uname -a
Linux zlive-platform-dapi-infra-dev-hhvmdebug-03 2.6.32-220.23.1.el6.x86_64 #1 SMP Mon Jun 18 18:58:52 BST 2012 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: