错误 - 当前位置没有可用的源代码
当我尝试调试在 Linux 计算机上编写的 C 程序时(现在,我使用的是 Visual C++ Express),我首先收到堆栈溢出错误。因此,当我单击“继续”时,我收到另一条错误消息,
读取位置0x00030000时访问冲突
所以我决定一步步调试。所以当我尝试它时,它会显示错误
当前位置没有可用的源代码。
出现这个错误的原因是什么?
代码
#if 1
while(1)
#endif
{
fillList();
#if 1
{
op_ds_bulk(ops, &total, 1);
temp = res("Bulk Write:", total, fp);
index = 0;
}
#endif
void op_ds_bulk(u_int ops, u_int * totalp, int update)
{
char encode_db[] = "encode";
if(update)
{
database_insert_bluk(list, ops);
database_sync();
*totalp = ops;
}
else
{
CHUNK prefetch[4096];
int random = rand() % (h-ops+1);
__os_clock(NULL, &start_time.secs, &start_time.usecs);
database_select_end(65546, random, prefetch, ops);
__os_clock(NULL, &end_time.secs, &end_time.usecs);
*totalp = ops;
}
}
}
When I'm trying to debug a C program written on Linux machine (right now, I'm using Visual C++ Express), I first get a stack overflow error. So when I clicked continue, I got another error message,
Access violation reading location 0x00030000
So I decide to debug step by step. So when I try it, it shows me the error
There is no source code available for the current location.
What is the reason for this error?
The Code
#if 1
while(1)
#endif
{
fillList();
#if 1
{
op_ds_bulk(ops, &total, 1);
temp = res("Bulk Write:", total, fp);
index = 0;
}
#endif
void op_ds_bulk(u_int ops, u_int * totalp, int update)
{
char encode_db[] = "encode";
if(update)
{
database_insert_bluk(list, ops);
database_sync();
*totalp = ops;
}
else
{
CHUNK prefetch[4096];
int random = rand() % (h-ops+1);
__os_clock(NULL, &start_time.secs, &start_time.usecs);
database_select_end(65546, random, prefetch, ops);
__os_clock(NULL, &end_time.secs, &end_time.usecs);
*totalp = ops;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无效访问可能发生在标准库代码中的某个位置。 Express 版本中不提供该源代码。
您可以检查调用堆栈中调用库函数的代码部分,并从那里开始工作。
The invalid access might occur somewhere in the standard library code. The source for that is not available in the Express edition.
You might check the call stack for the part of your code that calls a library function, and work it from there.
前段时间我也遇到过类似的问题,请问和你的问题有关系吗?
我在堆栈上有一个数组(你也有一个 -
预取
),我不小心将其清除得太远(超出数组范围),删除了数组之外的所有信息。当您调用函数时,返回地址也存储在堆栈中(计算机必须知道从函数返回的位置)。由于我已经清除了这一点,程序跳转到地址 0x0 和 SegFault-ed 下。调试时,我还收到一条消息“当前位置没有源代码”,因为“当前位置”是0x0,当然那里没有代码。
所以我怀疑你在堆栈上的某个数组上超出了界限。
通过查看您的代码,我看到两个可疑的事情:
您的预取数组的大小是 4096,但您使用参数 65546 调用
database_select_end
。也许没问题(不知道该函数的作用) 但也许不是;)65546 不是 2 的幂。2^16=65536
Some time ago I had a similar problem, maybe it is related to yours?
I had an array on the stack (you have one too -
prefetch
) and I accidently cleared it too far (out of bounds of the array), removing whatever information was beyond the array.When you call a function, the return address is also stored on the stack (computer must know where to return from a function). Since I have cleared that, the program jumped under address 0x0 and SegFault-ed. When debugging, I also got a message "there is no source code at current location", because "current location" was 0x0 and of course there was no code there.
So I suspect that you go out-of-bounds on some array which is on the stack.
By looking at your code, I see two suspicious things:
The size of your prefetch array is 4096, but you call
database_select_end
with parameter 65546. Maybe it is ok (no idea what that function does) but maybe it is not ;)65546 is not a power of 2. 2^16=65536
我通过使用不同的函数名称编写相同的代码解决了这个问题。这对我来说很奇怪,因为它解决了我的问题。我不知道为什么。
I solved the problem by writing the same code with a different function name. It's so weird for me because it solved my problem. I don't know why.