堆栈溢出和内存问题? [英] Stack overflow and memory problem?

查看:78
本文介绍了堆栈溢出和内存问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我遇到软件崩溃时,软件总是弹出一些东西

就像 0x1000a1eb处的指令

" 0x000000c0"中引用的内存。内存无法读取"

然后Visual C ++将询问我是否调试程序(在汇编中)。


我的朋友告诉我这主要是由于堆栈溢出造成的。他是对的吗?

是否有关于如何调试它的文件?


如何避免C和C ++中的这个错误?


一切顺利,

Davy

解决方案

>当我遇到软件崩溃,软件总是弹出一些东西

喜欢 0x1000a1eb处的指令引用内存在
0x000000c0。内存无法读取"
然后Visual C ++将询问我是否调试程序(在汇编中)。

我的朋友告诉我这主要是由堆栈引起的溢出。他是对的吗?
是否有关于如何调试它的文档?

如何避免C和C ++中的这个错误?




有很多原因可能导致这样的崩溃。

堆栈溢出距离列表很远。


- 解除引用NULL指针

- 取消引用未初始化的指针。

- 数组下标超出范围

- 在malloc()未返回的指针上调用free()或者free()ing

两次

- 将数组的末尾写入指针变量,然后使用



引用的内存地址的低值表示取消引用结构的NULL指针的可能性:

(( struct foo *)NULL) - >吧

但很难确定。


Gordon L. Burditt


2005年11月4日星期五07:12:01 -0000, go***********@burditt.org (Gordon

Burditt)写道:

当我遇到软件崩溃时,软件总会弹出一些像 0x1000a1eb处的指令引用内存在
0x000000c0。内存无法读取"
然后Visual C ++将询问我是否调试程序(在汇编中)。

我的朋友告诉我这主要是由堆栈引起的溢出。他是对的吗?
是否有关于如何调试它的文档?

如何避免C和C ++中的这个错误?



有很多原因你可能会像这样崩溃。
堆栈溢出在列表中很远。

- 解除引用NULL指针
- 取消引用未初始化的指针。 /> - 数组下标超出范围
- 在malloc()未返回的指针上调用free(),或者free()ing
两次
- 写下数组的结尾然后使用





引用的内存地址的低值表明取消引用结构的NULL指针的可能性:
((struct foo *)NULL) - >吧
但很难确定。

Gordon L. Burditt



是的,几乎每次我在一个程序中崩溃时,它就会取消引用一个空指针。


- Zara


戈登列出了许多可信的原因。此外,尝试将调试

信息添加到您的程序中,您不必在

汇编中查看它,从而更容易理解错误。 Tony


When I encounter software crash, the software always pop-up something
like " The instruction at "0x1000a1eb" referenced memory at
"0x000000c0". The memory could not be "read"".
Then Visual C++ will ask me whether to debug the program(in assembly).

My friend told me it is mostly cause by stack overflow. Is he right?
And is there any document on how to debug it?

And how to avoid this bug in C and C++?

All the best,
Davy

解决方案

>When I encounter software crash, the software always pop-up something

like " The instruction at "0x1000a1eb" referenced memory at
"0x000000c0". The memory could not be "read"".
Then Visual C++ will ask me whether to debug the program(in assembly).

My friend told me it is mostly cause by stack overflow. Is he right?
And is there any document on how to debug it?

And how to avoid this bug in C and C++?



There are a number of reasons you could get a crash like this.
Stack overflow is pretty far down the list.

- Dereferencing NULL pointers
- Dereferencing uninitialized pointers.
- Array subscript out of range
- calling free() on a pointer not returned by malloc(), or free()ing
something twice
- Writing off the end of an array into a pointer variable, which
is then used.

The low value for the memory address referenced suggests the
possibility of dereferencing a NULL pointer to a structure:
((struct foo *)NULL)->bar
but it''s difficult to be sure.

Gordon L. Burditt


On Fri, 04 Nov 2005 07:12:01 -0000, go***********@burditt.org (Gordon
Burditt) wrote:

When I encounter software crash, the software always pop-up something
like " The instruction at "0x1000a1eb" referenced memory at
"0x000000c0". The memory could not be "read"".
Then Visual C++ will ask me whether to debug the program(in assembly).

My friend told me it is mostly cause by stack overflow. Is he right?
And is there any document on how to debug it?

And how to avoid this bug in C and C++?



There are a number of reasons you could get a crash like this.
Stack overflow is pretty far down the list.

- Dereferencing NULL pointers
- Dereferencing uninitialized pointers.
- Array subscript out of range
- calling free() on a pointer not returned by malloc(), or free()ing
something twice
- Writing off the end of an array into a pointer variable, which
is then used.

The low value for the memory address referenced suggests the
possibility of dereferencing a NULL pointer to a structure:
((struct foo *)NULL)->bar
but it''s difficult to be sure.

Gordon L. Burditt


Yes, almost every time I have a crash lihe that ina program, it comes
form dereferencing a NULL pointer.

-- Zara


Gordon''s listed many plausible causes. Further, try adding debug
information to your program, and you shouldn''t have to look at it in
assembly, making it much easier to understand the error. Tony


这篇关于堆栈溢出和内存问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆