需求:
在使用原版Apache AB进行压力/性能测试的过程中,当完成请求次数超过2千2百万的时候,Apache AB在统计“Sorted on total connect times”的时候,会出现由于数组越界而引起的Segmentation fault的问题。
解决方案:
1. 引发血案的原因:
首先,在32位机器上,int数据类型的最大值为2147483647。而Apache AB源码在统计“Sorted on total connect times”的时候,采用的代码如下所示:
/* Sorted on total connect times */
if (percentile && (done > 1)) {
printf("\nPercentage of the requests served within a certain time (ms)\n");
for (i = 0; i < sizeof(percs) / sizeof(int); i++) {
if (percs[i] <= 0)
printf(" 0%% <0> (never)\n");
else if (percs[i] >= 100)
printf(" 100%% %5" APR_TIME_T_FMT " (longest request)\n",
ap_round_ms(stats[done - 1].time));
else
printf(" %d%% %5" APR_TIME_T_FMT "\n", percs[i],
ap_round_ms(stats[(int) (done * percs[i] / 100)].time));
}
}
由于源码中 percs数组的值为:
int percs[] = {50, 66, 75, 80, 90, 95, 98, 99, 100};
因此, 当请求次数 done > 2千2百万,并乘与percs[7]=99的时候,已经超出int类型的最大值,因此导致stats数组越界,报出Segmentation fault的错误
2. 解决思路:
解决这个问题,其实很简单,只需要将源码:
ap_round_ms(stats[(int) (done * percs[i] / 100)].time)
替换为:
ap_round_ms(stats[(int) ((double)(done / 100) * percs[i])].time)
即可解决问题。
ok, 性能/压力测试工具Apache ab修改系列:part4 介绍完毕, 欢迎拍砖。转发请备注转自:100continue.iteye.com。 谢谢。
分享到:
相关推荐
本文简单介绍了Segmentation fault发生的原因,结合实际例子描述了内核向用户态程序发送SIGSEGV信号的流程。文中以实例回答了常见的一些SIGSEGV问题,例如“为什么函数返回了栈还可以访问?”、“为什么free()后的...
linux开发经常会发生Segmentation fault问题,这是网上看到的一篇博文,共享给大家;有需要的下载。
//识别--pPath是成员变量保存车头照片路径 cv::Mat plateImage = cv::imread(pPath.toUtf8().data());//要识别的车牌照片路径(要清晰,正面) //定义一个容器存放识别结果 //RunPiplineAsImage()根据你提供的...
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped g++/gcc都不能编译了,一直抱ld的问题。网上找了很多方法都不行,弄了好久终于搞定了
Linux下的段错误Segmentationfault产生的原因及调试方法经典.pdf
声明部分:unsigned char *chptr ;%s格式控制部分:{...}仔细看看,发现了这样一个问题,在打印字符串的时候,实际上是打印某个地址开始的所
讲述一下linux环境下的编译段错误分析
ISBI Challenge: Segmentation of neuronal structures in EM stacks 训练数据有30张,分辨率为512x512,这些图片是果蝇的电镜图。
———————————————— 版权声明:本文为CSDN博主「关关教你学编程」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:...
背景最近一段时间在linux下用C做一些学习和开发,但是由于经验足,问题多多。而段错误就是让我非常头痛的一个问题。过,目前写一个一千左右的代码,也很少出现段错误
segmentation_models_pytorch是一款非常优秀的图像分割库,albumentations 是一款非常优秀的图像增强库,这篇文章将这两款优秀结合起来实现多类别的图像分割算法。数据集选用CamVid数据集,类别有:'sky', 'building...
Word Segmentation:The Role of Distributional Cues.pdf
Unsupervised Part Segmentation Through Disentangling Appearance and Shape
Deep learning for cardiac image segmentation: A review 时间:2019.11 作者:帝国理工/伦敦大学/伯明翰大学 links:https://arxiv.org/abs/1911.03723 医学图像分割综述,从FCN(2014)-DenseUNet(2019) 相关...
图分割 这种图形分割算法最初是由 Pedro F. Felzenszwalb 开发的。...修改者:Suryansh Kumar、Ayush Dewan。 编写此代码的动机是使该算法与不同的图像格式兼容。 而且,OpenCV 是使用最广泛的计算机视觉库之一
DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs
Linux下的C程序常常会因为内存访问错误等原因造成segment fault(段错误),此时如果系统core dump功能是打开的,那么将会有内存映像转储到硬盘上来,之后可以用gdb对core文件进行分析,还原系统发生段错误时刻的堆栈...
4.error:divergence detected in AMG solver 5.error:temperature divergence detected in AMG solver 6.turbulent viscosity limited to viscosity ratio of 1.000000e+5 in 7.error:floating point error:...
Lecture 4: Single/multi-object tracking Lecture 5: Multiple object tracking (Message Passing Networks) Lecture 6: Pedestrian Trajectory Prediction (GANs) Lecture 7: Semantic segmentation Lecture 8: ...
"多变量分析"——数据挖掘、数据分析 I。多重对应分析 多重对应分析在超过两个以上定类变量时有时候⾮常有效,当然⾸先我们要理解并思考,如果只有三个或有限的⼏个变量完全可以通过数据变换和交互表变量重 组可以...