tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54085] New: ssl_socket_recv sometimes loops infinitely with non-blocking sockets
Date Thu, 01 Nov 2012 12:47:47 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54085

          Priority: P2
            Bug ID: 54085
          Assignee: dev@tomcat.apache.org
           Summary: ssl_socket_recv sometimes loops infinitely with
                    non-blocking sockets
          Severity: normal
    Classification: Unclassified
                OS: Linux
          Reporter: andrei@art.su
          Hardware: PC
            Status: NEW
           Version: 1.1.24
         Component: Library
           Product: Tomcat Native

Java-based server using Tomcat Native sometimes falls into a busy loop
consuming 100% CPU.
The native stack trace of the problem:

Thread 58 (Thread 1249868096 (LWP 29778)):
#0  0x00007fdf3ca93e6b in __read_nocancel () from /lib64/libpthread.so.0
#1  0x00007fdf2205f092 in sock_read (b=0x7fdec7bc58a0, out=0x7fdeb0b31448,
outl=3869) at /usr/include/bits/unistd.h:35
#2  0x00007fdf2205d56f in BIO_read (b=0x7fdec7bc58a0, out=0x7fdeb0b31448,
outl=3869) at bio_lib.c:212
#3  0x00007fdf2234795b in ssl3_read_n (s=0x7fdec5a51340, n=6624, max=6624,
extend=<value optimized out>) at s3_pkt.c:199
#4  0x00007fdf22347efe in ssl3_read_bytes (s=0x7fdec5a51340, type=23,
buf=0x7fdeb9a70000, len=4096, peek=0) at s3_pkt.c:324
#5  0x00007fdf223458c8 in ssl3_read (s=0x7fdec5a51340, buf=0x7fdeb9a70000,
len=4096) at s3_lib.c:2574
#6  0x00007fdf2258c36e in ssl_socket_recv (sock=0x7fdeb9b2c8b0,
buf=0x7fdeb9a70000, len=0x4a7f6a38) at src/sslnetwork.c:397
#7  0x00007fdf2258aa10 in Java_org_apache_tomcat_jni_Socket_recvbt (e=<value
optimized out>, o=<value optimized out>, sock=140594574968408, buf=<value
optimized out>, offset=0, len=<value optimized out>, timeout=1000) at
src/network.c:972

The infinite loop appears to be in ssl_socket_recv() with the following
scenario:
1. SSL_read() at line 397 returns -1;
2. apr_get_netos_error() at line 398 returns EAGAIN;
3. SSL_get_error() at line 402 returns SSL_ERROR_SSL.

The socket is in O_NONBLOCK mode. SSL handshake has passed.

Here is the patch that helped me to overcome the problem:

*** sslnetwork.c
--- sslnetwork-patched.c
***************
*** 420,429 ****
                  break;
                  case SSL_ERROR_SYSCALL:
                  case SSL_ERROR_SSL:
!                     if (!APR_STATUS_IS_EAGAIN(os) &&
!                         !APR_STATUS_IS_EINTR(os)) {
                          con->shutdown_type = SSL_SHUTDOWN_TYPE_UNCLEAN;
!                         return os == APR_SUCCESS ? APR_EGENERAL : os;
                      }
                  break;
                  default:
--- 420,428 ----
                  break;
                  case SSL_ERROR_SYSCALL:
                  case SSL_ERROR_SSL:
!                     if (!APR_STATUS_IS_EINTR(os)) {
                          con->shutdown_type = SSL_SHUTDOWN_TYPE_UNCLEAN;
!                         return os == APR_SUCCESS || APR_STATUS_IS_EAGAIN(os)
? APR_EGENERAL : os;
                      }
                  break;
                  default:

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message