-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gtest下mock类成员函数运行时coredump #12
Comments
看起来用法没有问题,猜测是不是和机型有关,触发的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位机器 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;
} 循环中两个判断 |
是最新代码编译的对吧,最新有一次commit修复了之前last_end错误初始化的问题 |
@slllovehaski 应该修复了这个问题,确实是跳板申请的位置不对,我已经合了代码,辛苦有可能的话再试一下 |
The text was updated successfully, but these errors were encountered: