Comments (4)
看起来用法没有问题,猜测是不是和机型有关,触发的bug,是64位的吗
可以加上调试信息确认一下挂在哪一行不?现在只能看到是在获取蹦床的时候出的错
from emock.
看起来用法没有问题,猜测是不是和机型有关,触发的bug,是64位的吗
可以加上调试信息确认一下挂在哪一行不?现在只能看到是在获取蹦床的时候出的错
$: uname -a
Linux K 5.4.0-45-generic #49~18.04.2-Ubuntu SMP Wed Aug 26 16:29:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$: cat /etc/issue
Ubuntu 18.04.5 LTS \n \l
64位机器
普通函数mock是没有问题的,就成员函数mock时会coredump
TrampolineAllocate函数返回了空指针造成coredump
void* TrampolineAllocate(const unsigned char* dst, size_t alloc_size)
{
FILE* fp = fopen("/proc/self/maps", "r");
if(!fp) {
EMOCK_REPORT_FAILURE("Failed to fetch current proc maps");
return NULL;
}
unsigned long last_end = 0;
while(!feof(fp)) {
char buf[PATH_MAX + 100] = {0};
if(fgets(buf, sizeof(buf), fp) == 0)
break;
unsigned long begin, end = 0;
sscanf(buf, "%lx-%lx %*[^\n]", &begin, &end);
if(last_end && begin != last_end && begin - last_end > alloc_size) {
// alloc at end of last
if((size_t)(dst - (unsigned char*)last_end) < kMaxAllocationDelta) { // 条件不满足
if(void* allocated = TrampolineAllocateImpl(dst, alloc_size)) {
fclose(fp);
return allocated;
}
}
// alloc at begin of current
if((size_t)((unsigned char*)begin - dst) < kMaxAllocationDelta) { // 条件不满足
if(void* allocated = TrampolineAllocateImpl(dst - alloc_size, alloc_size)) {
fclose(fp);
return allocated;
}
}
}
last_end = end;
}
fclose(fp);
return NULL;
}
循环中两个判断if((size_t)(dst - (unsigned char*)last_end) < kMaxAllocationDelta)
if((size_t)((unsigned char*)begin - dst) < kMaxAllocationDelta)
都不满足,最后直接break返回NULL
from emock.
是最新代码编译的对吧,最新有一次commit修复了之前last_end错误初始化的问题
应该是当前内存页内没有找到跳板,这个case实在不行只能用longjump覆盖了,但demo里面的成员函数确实不够13字节,存在不安全的可能性
from emock.
@slllovehaski 应该修复了这个问题,确实是跳板申请的位置不对,我已经合了代码,辛苦有可能的话再试一下
from emock.
Related Issues (20)
- 你好,请问mock普通成员函数为什么会崩溃? HOT 2
- 同一个函数在目标被测函数中多次调用(会有不同结果)该如何mock? HOT 2
- MacOS 段错误 HOT 1
- 经常不知原因的段错误 HOT 4
- mock 类成员函数 失败 (虚函数 和 普通成员函数 都失败 ) HOT 2
- 有计划发布一个release版本么 HOT 3
- 连续mock两个不同的类内普通方法,发现走的同一个will() HOT 3
- VS2019 MSVC x64场景下mock类的普通成员函数时会奔溃,不能成功,详情分析见描述 HOT 3
- 请问能否mock protected属性的方法? HOT 5
- 当测函数有多个参数时还可以指定出参吗? HOT 11
- mingw64无法编译通过 HOT 6
- 请问下模板函数如何mock HOT 1
- 请问桩函数能否使用lambda表达式 HOT 3
- 虚函数打桩失败 HOT 3
- defined but not used [-Wunused-function] HOT 1
- 尝试对QTextStream的符号重载函数打桩失败 HOT 1
- 在ARM LINUX上跑的时候报错 非法指令 HOT 1
- wsl ubuntu环境下mock 类成员函数 出现段错误 HOT 6
- Cannot build in windows HOT 6
- 文档 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emock.