1

在这段代码中:

...
size_t bytes_over=0;    //Number of bytes overthe region.
size_t byte_size=0; //Number of bytes overthe region.

if(isin_allocatedblock(mem, key_address,&bytes_over,&byte_size))
{
//** Seg Fault here
asprintf(err_msg_2nd,"%s:%d: %p is %Zu bytes inside a %Zu byte region allocated here\n",file, line, key_address, bytes_over,byte_size);
    }
...
}


bool isin_allocatedblock(struct memory *mem, char *key_address, size_t *bytes_over, size_t *byte_size) {
...
*bytes_over = (previous_alloc_ptr+prev_alloc_sz) - key_address; //Right side is 1901
*byte_size = get_metadata_recordsize(meta_rec); 
return true;
}

当在 gdb 中打印 bytes_over 时,它被分配了我得到的新值

$17 = <unknown type>

当我打印 byte_size 我得到:

Function return type unknown.

我在 asprint 命令上遇到了段错误,所以我试图查看这两个变量的值。我在 gdb 中“设置了投诉 5”,现在我在 gdb 中运行后看到了这一点(行号是 bytes_over 分配给它的值的行):

During symbol reading, incomplete CFI data; unspecified registers (e.g., esi) at 0x8049acc.
isin_allocatedblock (mem=0x804cec8, key_address=0x804de64 "", bytes_over=
    0xbffff078, byte_size=0xbffff074) at memory.c:471
4

0 回答 0