linux – 当速率很高时检测到httperf缓冲区溢出
作者:互联网
我在Ubuntu 12.04.1 LTS 64位上运行httperf 0.9.0(downloaded from Google Code),带有2CPU和4GB RAM.我正在尝试对Web服务器进行基准测试,但遇到了以下缓冲区溢出问题.
终端命令:
httperf --timeout=5 --client=0/1 --server=localhost --port=9090 --uri=/?value=benchmarks --rate=1200 --send-buffer=4096 --recv-buffer=16384 --num-conns=5000 --num-calls=10
运行几秒后,它崩溃了:
*** buffer overflow detected ***: httperf terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f1f5efa1007]
/lib/x86_64-linux-gnu/libc.so.6(+0x107f00)[0x7f1f5ef9ff00]
/lib/x86_64-linux-gnu/libc.so.6(+0x108fbe)[0x7f1f5efa0fbe]
httperf[0x404054]
httperf[0x404e9f]
httperf[0x406953]
httperf[0x406bd1]
httperf[0x40639f]
httperf[0x4054d5]
httperf[0x40285e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f1f5eeb976d]
httperf[0x4038f1]
======= Memory map: ========
...
...
7f1f5fd74000-7f1f5fd79000 rw-p 00000000 00:00 0
7f1f5fd91000-7f1f5fd95000 rw-p 00000000 00:00 0
7f1f5fd95000-7f1f5fd96000 r--p 00022000 08:03 4849686 /lib/x86_64-linux-gnu/ld-2.15.so
7f1f5fd96000-7f1f5fd98000 rw-p 00023000 08:03 4849686 /lib/x86_64-linux-gnu/ld-2.15.so
7fff10452000-7fff10473000 rw-p 00000000 00:00 0 [stack]
7fff1054f000-7fff10550000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
我用gdb检查了the core dump file如下:
(gdb) list
198 event_signal (EV_PERF_SAMPLE, 0, callarg);
199
200 /* prepare for next sample interval: */
201 perf_sample_start = timer_now ();
202 timer_schedule (perf_sample, regarg, RATE_INTERVAL);
203 }
204
205 int
206 main (int argc, char **argv)
207 {
(gdb) bt
#0 0x00007f33d4643445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f33d4646bab in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f33d4680e2e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007f33d4716007 in __fortify_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007f33d4714f00 in __chk_fail () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007f33d4715fbe in __fdelt_warn () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x0000000000404054 in set_active (s=<optimized out>, fdset=0x612bc0) at core.c:367
#7 0x0000000000404e9f in core_connect (s=0x17e7100) at core.c:980
#8 0x0000000000406953 in make_conn (arg=...) at conn_rate.c:64
#9 0x0000000000406bd1 in tick (t=<optimized out>, arg=...) at rate.c:94
#10 0x000000000040639f in timer_tick () at timer.c:104
#11 0x00000000004054d5 in core_loop () at core.c:1255
#12 0x000000000040285e in main (argc=11, argv=<optimized out>) at httperf.c:971
我稍微跟踪了源代码,发现FD_SET似乎是原因.
最后,对于较低的费率(例如–rate = 100或–rate = 500),httperf工作正常.我正在对不同的Web服务器进行基准测试,导致崩溃的速率不同.我的费率从100到1200不等.
有关更多详细信息,实际上我正在尝试重复the experiments done by Roberto Ostinelli,并且我已经调整了TCP设置并应用了他的博客文章中提到的补丁.
是什么导致这个问题?谢谢!
解决方法:
您正在尝试使用>的fd. 1024.
在低负载下,您不需要/使用那么多的fds.
在高负载下,您需要更多fds,最终达到1024
这导致了问题.
即使我增加__FD_SETSIZE我也遇到了这个问题,
所以我认为无论代码是什么都存在错误
做绑定检查(gcc / llvm?)
标签:buffer-overflow,linux,crash,httperf 来源: https://codeday.me/bug/20190725/1537293.html