lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

test_unknown_user sometimes fails (lwan segfaults) on Alpine Linux #214

Closed jirutka closed 6 years ago

jirutka commented 6 years ago
======================================================================
ERROR: test_unknown_user (__main__.TestAuthentication)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

I tried to start testrunner manually:

echo "foo = bar" > htpasswd
strace -f ./src/bin/testrunner/testrunner

And send some request with HTTP Basic:

curl -u foo:bar http://0.0.0.0:8080/admin

Sometimes it correctly responds with Hello, world!, sometimes it segfaults:

 <unfinished ...>
[pid 31169] <... accept4 resumed> )     = 77
[pid 31169] write(48, "M\0\0\0", 4)     = 4
[pid 31169] accept4(76, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK <unfinished ...>
[pid 31185] <... epoll_pwait resumed> [{EPOLLIN, {u32=0, u64=0}}], 170, -1, NULL, 8) = 1
[pid 31185] read(47, "M\0\0\0", 4)      = 4
[pid 31185] epoll_ctl(46, EPOLL_CTL_ADD, 77, {EPOLLIN|EPOLLERR|EPOLLRDHUP|EPOLLET, {u32=1412061600, u64=314944674208}}) = 0
[pid 31185] epoll_pwait(46, [{EPOLLIN, {u32=1412061600, u64=314944674208}}], 170, 1000, NULL, 8) = 1
[pid 31185] read(77, "GET /admin HTTP/1.1\r\nHost: 0.0.0"..., 4096) = 116
[pid 31185] brk(0x49542cf000)           = 0x49542cf000
[pid 31185] open("htpasswd", O_RDONLY|O_CLOEXEC) = 79
[pid 31185] fcntl(79, F_SETFD, FD_CLOEXEC) = 0
[pid 31185] fstat(79, {st_mode=S_IFREG|0644, st_size=10, ...}) = 0
[pid 31185] mmap(NULL, 10, PROT_READ, MAP_SHARED, 79, 0) = 0x283a5967000
[pid 31185] close(79)                   = 0
[pid 31185] munmap(0x283a5967000, 10)   = 0
[pid 31185] writev(77, [{iov_base="HTTP/1.1 200 OK\r\nContent-Length:"..., iov_len=224}, {iov_base="Hello, world!", iov_len=13}], 2) = 237
[pid 31185] epoll_ctl(46, EPOLL_CTL_MOD, 77, {EPOLLOUT|EPOLLERR|EPOLLRDHUP, {u32=1412061600, u64=314944674208}}) = 0
[pid 31185] epoll_pwait(46, [{EPOLLOUT|EPOLLRDHUP, {u32=1412061600, u64=314944674208}}], 170, 1000, NULL, 8) = 1
[pid 31185] close(77)                   = 0
[pid 31185] epoll_pwait(46,  <unfinished ...>
[pid 31169] <... accept4 resumed> )     = 78
[pid 31169] write(48, "N\0\0\0", 4)     = 4
[pid 31185] <... epoll_pwait resumed> [{EPOLLIN, {u32=0, u64=0}}], 170, -1, NULL, 8) = 1
[pid 31169] accept4(76, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK <unfinished ...>
[pid 31185] read(47, "N\0\0\0", 4)      = 4
[pid 31185] epoll_ctl(46, EPOLL_CTL_ADD, 78, {EPOLLIN|EPOLLERR|EPOLLRDHUP|EPOLLET, {u32=1412061632, u64=314944674240}}) = 0
[pid 31185] brk(0x49542d0000)           = 0x49542d0000
[pid 31185] epoll_pwait(46, [{EPOLLIN, {u32=1412061632, u64=314944674240}}], 170, 1000, NULL, 8) = 1
[pid 31185] read(78, "GET /admin HTTP/1.1\r\nHost: 0.0.0"..., 4096) = 116
[pid 31185] --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} ---
[pid 31191] <... epoll_pwait resumed> ) = ? <unavailable>
[pid 31192] <... epoll_pwait resumed> <unfinished ...>) = ?
[pid 31194] <... epoll_pwait resumed> <unfinished ...>) = ?
[pid 31169] <... accept4 resumed>)      = ?
[pid 31193] <... epoll_pwait resumed> <unfinished ...>) = ?
...
[pid 31171] <... epoll_pwait resumed> <unfinished ...>) = ?
[pid 31170] <... futex resumed>)        = ?
[pid 31186] <... epoll_pwait resumed> <unfinished ...>) = ?
[pid 31186] +++ killed by SIGSEGV +++
...
[pid 31170] +++ killed by SIGSEGV +++
+++ killed by SIGSEGV +++
Segmentation fault

lwan-build-config.h:

#pragma once

/* API available in Glibc/Linux, but possibly not elsewhere */
#define HAS_ACCEPT4
#define HAS_CLOCK_GETTIME
#define HAS_MEMPCPY
#define HAS_MEMRCHR
#define HAS_PIPE2
#define HAS_PTHREADBARRIER
/* #undef HAS_RAWMEMCHR */
#define HAS_READAHEAD
/* #undef HAS_REALLOCARRAY */
#define HAS_MKOSTEMP

/* Compiler builtins for specific CPU instruction support */
#define HAVE_BUILTIN_CLZLL
#define HAVE_BUILTIN_CPU_INIT
#define HAVE_BUILTIN_IA32_CRC32
#define HAVE_BUILTIN_MUL_OVERFLOW
#define HAVE_BUILTIN_ADD_OVERFLOW

/* C11 _Static_assert() */
#define HAVE_STATIC_ASSERT

/* Libraries */
#define HAVE_LUA

/* Valgrind support for coroutines */
/* #undef USE_VALGRIND */
lpereira commented 6 years ago

I've pushed a nasty fix to HEAD (3721cbe), that should address this issue. Could you please test again and confirm this fixes the issue?

lpereira commented 6 years ago

Closing issue as fixed.