lpereira / lwan

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

lwan alway failed to quit with a double free error after caught SIGINT #121

Closed Arondight closed 8 years ago

Arondight commented 9 years ago

Copy lwan to anthor directory and run it with -r, then type Ctrl+C and lwan will crash everytime, both in Debug and Release build type. Sorry for my bad English, here is what I have done with log of Debug version. I think this is a bug so I report, I am very sorry if it is not.

~/Codes/lwan(branch:master*) » cp build/lwan/lwan a
------------------------------------------------------------
~/Codes/lwan(branch:master*) » md5sum build/lwan/lwan a | awk '{print $1}' | uniq -c
      2 05c1c4d5325410813de72a069bd804e0
------------------------------------------------------------
~/Codes/lwan(branch:master*) » ./a -r wwwroot
4928 main.c:234 main() Serving files from wwwroot.
4928 lwan-job.c:79 lwan_job_thread_init() Initializing low priority job thread.
4928 lwan-response.c:75 lwan_response_init() Initializing default response.
4928 lwan-tables.c:40 lwan_tables_init() Uncompressing MIME type table.
4928 lwan.c:59 lwan_module_init() Initializing module registry.
4928 lwan.c:541 lwan_init_with_config() Initializing lwan web server.
4928 lwan.c:556 lwan_init_with_config() Using 4 threads, maximum 1024 sockets per thread.
4928 lwan-thread.c:437 lwan_thread_init() Initializing threads.
4928 lwan-socket.c:233 lwan_socket_init() Initializing sockets.
4931 lwan-thread.c:335 thread_io_loop() Starting IO loop on thread #2.
4932 lwan-thread.c:335 thread_io_loop() Starting IO loop on thread #3.
4933 lwan-thread.c:335 thread_io_loop() Starting IO loop on thread #4.
4928 lwan-socket.c:152 listen_addrinfo() Listening on http://0.0.0.0:8080.
4930 lwan-thread.c:335 thread_io_loop() Starting IO loop on thread #1.
4928 lwan.c:629 lwan_main_loop() Ready to serve.
^C4928 lwan.c:640 lwan_main_loop() Signal 2 (Interrupt) received.
4928 lwan.c:568 lwan_shutdown() Shutting down.
4928 lwan-job.c:98 lwan_job_thread_shutdown() Shutting down job thread.
4928 lwan-thread.c:450 lwan_thread_shutdown() Shutting down threads.
4928 lwan-thread.c:458 lwan_thread_shutdown() Closing epoll for thread 3 (fd=12).
4928 lwan-thread.c:458 lwan_thread_shutdown() Closing epoll for thread 2 (fd=9).
4928 lwan-thread.c:458 lwan_thread_shutdown() Closing epoll for thread 1 (fd=6).
4928 lwan-thread.c:458 lwan_thread_shutdown() Closing epoll for thread 0 (fd=3).
4928 lwan-thread.c:481 lwan_thread_shutdown() Waiting for thread 3 to finish.
4928 lwan-thread.c:485 lwan_thread_shutdown() Closing pipe (13, 14).
4928 lwan-thread.c:481 lwan_thread_shutdown() Waiting for thread 2 to finish.
4928 lwan-thread.c:485 lwan_thread_shutdown() Closing pipe (10, 11).
4928 lwan-thread.c:481 lwan_thread_shutdown() Waiting for thread 1 to finish.
4928 lwan-thread.c:485 lwan_thread_shutdown() Closing pipe (7, 8).
4928 lwan-thread.c:481 lwan_thread_shutdown() Waiting for thread 0 to finish.
4928 lwan-thread.c:485 lwan_thread_shutdown() Closing pipe (4, 5).
4928 lwan.c:576 lwan_shutdown() Shutting down URL handlers.
4928 lwan-cache.c:151 cache_destroy() Cache stats: 0 hits, 0 misses, 0 evictions.
4928 lwan-response.c:85 lwan_response_shutdown() Shutting down response.
4928 lwan-cache.c:151 cache_destroy() Cache stats: 0 hits, 0 misses, 0 evictions.
*** Error in `./a': double free or corruption (!prev): 0x00000000010a0c40 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72055)[0x7f63d6efc055]
/usr/lib/libc.so.6(+0x779a6)[0x7f63d6f019a6]
/usr/lib/libc.so.6(+0x7818e)[0x7f63d6f0218e]
./a(main+0x1b5)[0x40659a]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f63d6eaa610]
./a(_start+0x29)[0x405549]
======= Memory map: ========
00400000-00442000 r-xp 00000000 08:03 37105296                           /home/is/Codes/lwan/a
00641000-00670000 rw-p 00041000 08:03 37105296                           /home/is/Codes/lwan/a
00670000-0067b000 rw-p 00000000 00:00 0 
0108f000-010c1000 rw-p 00000000 00:00 0                                  [heap]
7f63bc000000-7f63bc021000 rw-p 00000000 00:00 0 
7f63bc021000-7f63c0000000 ---p 00000000 00:00 0 
7f63c4000000-7f63c4021000 rw-p 00000000 00:00 0 
7f63c4021000-7f63c8000000 ---p 00000000 00:00 0 
7f63c8000000-7f63c8021000 rw-p 00000000 00:00 0 
7f63c8021000-7f63cc000000 ---p 00000000 00:00 0 
7f63cc000000-7f63cc021000 rw-p 00000000 00:00 0 
7f63cc021000-7f63d0000000 ---p 00000000 00:00 0 
7f63d3def000-7f63d3df0000 ---p 00000000 00:00 0 
7f63d3df0000-7f63d45f0000 rw-p 00000000 00:00 0 
7f63d45f0000-7f63d45f1000 ---p 00000000 00:00 0 
7f63d45f1000-7f63d4df1000 rw-p 00000000 00:00 0 
7f63d4df1000-7f63d4df2000 ---p 00000000 00:00 0 
7f63d4df2000-7f63d55f2000 rw-p 00000000 00:00 0                          [stack:4931]
7f63d55f2000-7f63d55f3000 ---p 00000000 00:00 0 
7f63d55f3000-7f63d5df3000 rw-p 00000000 00:00 0 
7f63d5df3000-7f63d5df4000 ---p 00000000 00:00 0 
7f63d5df4000-7f63d65f4000 rw-p 00000000 00:00 0                          [stack:4929]
7f63d65f4000-7f63d660a000 r-xp 00000000 08:01 1065034                    /usr/lib/libgcc_s.so.1
7f63d660a000-7f63d6809000 ---p 00016000 08:01 1065034                    /usr/lib/libgcc_s.so.1
7f63d6809000-7f63d680a000 rw-p 00015000 08:01 1065034                    /usr/lib/libgcc_s.so.1
7f63d680a000-7f63d6907000 r-xp 00000000 08:01 1065986                    /usr/lib/libm-2.22.so
7f63d6907000-7f63d6b06000 ---p 000fd000 08:01 1065986                    /usr/lib/libm-2.22.so
7f63d6b06000-7f63d6b07000 r--p 000fc000 08:01 1065986                    /usr/lib/libm-2.22.so
7f63d6b07000-7f63d6b08000 rw-p 000fd000 08:01 1065986                    /usr/lib/libm-2.22.so
7f63d6b08000-7f63d6c7a000 r-xp 00000000 08:01 1065437                    /usr/lib/libstdc++.so.6.0.21
7f63d6c7a000-7f63d6e7a000 ---p 00172000 08:01 1065437                    /usr/lib/libstdc++.so.6.0.21
7f63d6e7a000-7f63d6e84000 r--p 00172000 08:01 1065437                    /usr/lib/libstdc++.so.6.0.21
7f63d6e84000-7f63d6e86000 rw-p 0017c000 08:01 1065437                    /usr/lib/libstdc++.so.6.0.21
7f63d6e86000-7f63d6e8a000 rw-p 00000000 00:00 0 
7f63d6e8a000-7f63d7025000 r-xp 00000000 08:01 1063429                    /usr/lib/libc-2.22.so
7f63d7025000-7f63d7224000 ---p 0019b000 08:01 1063429                    /usr/lib/libc-2.22.so
7f63d7224000-7f63d7228000 r--p 0019a000 08:01 1063429                    /usr/lib/libc-2.22.so
7f63d7228000-7f63d722a000 rw-p 0019e000 08:01 1063429                    /usr/lib/libc-2.22.so
7f63d722a000-7f63d722e000 rw-p 00000000 00:00 0 
7f63d722e000-7f63d726c000 r-xp 00000000 08:01 1065475                    /usr/lib/libubsan.so.0.0.0
7f63d726c000-7f63d746b000 ---p 0003e000 08:01 1065475                    /usr/lib/libubsan.so.0.0.0
7f63d746b000-7f63d746d000 rw-p 0003d000 08:01 1065475                    /usr/lib/libubsan.so.0.0.0
7f63d746d000-7f63d7f3e000 rw-p 00000000 00:00 0 
7f63d7f3e000-7f63d7f56000 r-xp 00000000 08:01 1062847                    /usr/lib/libpthread-2.22.so
7f63d7f56000-7f63d8155000 ---p 00018000 08:01 1062847                    /usr/lib/libpthread-2.22.so
7f63d8155000-7f63d8156000 r--p 00017000 08:01 1062847                    /usr/lib/libpthread-2.22.so
7f63d8156000-7f63d8157000 rw-p 00018000 08:01 1062847                    /usr/lib/libpthread-2.22.so
7f63d8157000-7f63d815b000 rw-p 00000000 00:00 0 
7f63d815b000-7f63d8170000 r-xp 00000000 08:01 1065629                    /usr/lib/libz.so.1.2.8
7f63d8170000-7f63d836f000 ---p 00015000 08:01 1065629                    /usr/lib/libz.so.1.2.8
7f63d836f000-7f63d8370000 r--p 00014000 08:01 1065629                    /usr/lib/libz.so.1.2.8
7f63d8370000-7f63d8371000 rw-p 00015000 08:01 1065629                    /usr/lib/libz.so.1.2.8
7f63d8371000-7f63d8374000 r-xp 00000000 08:01 1065985                    /usr/lib/libdl-2.22.so
7f63d8374000-7f63d8573000 ---p 00003000 08:01 1065985                    /usr/lib/libdl-2.22.so
7f63d8573000-7f63d8574000 r--p 00002000 08:01 1065985                    /usr/lib/libdl-2.22.so
7f63d8574000-7f63d8575000 rw-p 00003000 08:01 1065985                    /usr/lib/libdl-2.22.so
7f63d8575000-7f63d8597000 r-xp 00000000 08:01 1063428                    /usr/lib/ld-2.22.so
7f63d8762000-7f63d876a000 rw-p 00000000 00:00 0 
7f63d8790000-7f63d8796000 rw-p 00000000 00:00 0 
7f63d8796000-7f63d8797000 r--p 00021000 08:01 1063428                    /usr/lib/ld-2.22.so
7f63d8797000-7f63d8798000 rw-p 00022000 08:01 1063428                    /usr/lib/ld-2.22.so
7f63d8798000-7f63d8799000 rw-p 00000000 00:00 0 
7ffd48eaa000-7ffd48ecb000 rw-p 00000000 00:00 0                          [stack]
7ffd48f5c000-7ffd48f5e000 r--p 00000000 00:00 0                          [vvar]
7ffd48f5e000-7ffd48f60000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
[1]    4928 abort (core dumped)  ./a -r wwwroot

Here some information may be help

~/Codes/lwan(branch:master*) » g lg | head -5
commit 27a845f0ec6f7afda547bf85636fc9e8239ba3b6
Author: Leandro Pereira <leandro@hardinfo.org>
Date:   Wed Nov 4 08:19:57 2015 -0200

    Use proper address structures for proxy protocol union
~/Codes/lwan(branch:master*) » g st
位于分支 master
您的分支与上游分支 'origin/master' 一致。
未跟踪的文件:
  (使用 "git add <文件>..." 以包含要提交的内容)

    a

提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)
~/Codes/lwan(branch:master*) » uname -srm
Linux 4.2.5-1-ARCH x86_64
~/Codes/lwan(branch:master*) » pacman -Q glibc
glibc 2.22-3
lpereira commented 9 years ago

This looks like a bug, yes. Could you please run Lwan under gdb to get a backtrace?

Arondight commented 9 years ago

I am sorry it may take me some time to learn gdb skills and I am busy for my first work as a graduate. After compare of my pc and company's, both are Arch Linux, the only different is I create some links for old libs to do develpment on Android at company , here is a list. Also, this issuse can recurrent on Ubuntu 14.04 desktop version every time, for it has libtinfo and libncurses but no libncursesw.

lpereira commented 9 years ago

I was able to reproduce a crash while quitting Lwan on my computer, it might be the same one you've reported. I'll try to fix it ASAP.