473,414 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Stack overflow and memory problem?

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

Nov 4 '05 #1
11 3784
>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
Nov 4 '05 #2
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
Nov 4 '05 #3
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

Nov 4 '05 #4
The crash you are experiencing could be due to any number of reasons.

The following articles might help:

http://www.eventhelix.com/RealtimeMa...re_crashes.htm

http://www.eventhelix.com/RealtimeMa..._crashes_2.htm

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Object Modeling Tool

Nov 4 '05 #5
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.

In this particular case, probably dereferencing 0xc0 pointer :-),
which is equally fatal as NULL. Also, address of the instruction
suggests that this is probably somewhere in startup code of a Dll
(default base adress 0x10000000).

<I'm not sure why clc and clc++ are in newsgroup list>

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
Nov 4 '05 #6
In message <11**********************@g47g2000cwa.googlegroups .com>,
EventHelix.com <ev********@gmail.com> writes
The crash you are experiencing could be due to any number of reasons.

The following articles might help:

http://www.eventhelix.com/RealtimeMa...re_crashes.htm

http://www.eventhelix.com/RealtimeMa...ing_software_c
rashes_2.htm


If you've read those two URLs you'll be aware of memory corruption,
buffer overruns, uninitialised variables and also flow tracing. Two
products that can help with these issues are Memory Validator and Crash
Validator.

http://www.softwareverify.com

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
Nov 4 '05 #7
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).

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.


Doesn't VC initialize all variables to 0xc0 in debug mode? so this
looks like dereferencing an uninitialized pointer.

Isn't it funny how they put "read" in quotes, as if "reading" memory
were some esoteric concept?!

--
Lucian
Nov 4 '05 #8
Lucian Wischik wrote:

Doesn't VC initialize all variables to 0xc0 in debug mode? so this
looks like dereferencing an uninitialized pointer.

OT, but what the hell... VC initializes to 0xcccccccc in debug mode.
Nov 4 '05 #9
In message <qi********************************@4ax.com>, Lucian Wischik
<lu***@wischik.com> writes
Doesn't VC initialize all variables to 0xc0 in debug mode? so this
looks like dereferencing an uninitialized pointer.


Static variables. 0x00000000 (I think)
CRT variables: 0xcdcdcdcd
Win32 Heap variables 0xbaadf00d
Stack Variables: 0xcccccccc

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
Nov 5 '05 #10
Yvad wrote:
My friend told me it is mostly cause by stack overflow. Is he right?
No.
And is there any document on how to debug it?
I assume you have the source code.

If so just compile the applicaiton with debug information and
run the program in the debugger. The debugger call stack will
show you why the program is crashing.
And how to avoid this bug in C and C++?


Don't write buggy code ;)

Jussi Jumppanen
Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor
"The C/C++, Java, HTML, FTP, Python, PHP, Perl folding editor"
http://www.zeusedit.com
Nov 9 '05 #11

If you've read those two URLs you'll be aware of memory corruption,
buffer overruns, uninitialised variables and also flow tracing. Two
products that can help with these issues are Memory Validator and Crash
Validator.

http://www.softwareverify.com

I think Numega's BoundsChecker is also a good tool to find memory
corruption.
Nov 9 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
7
by: Aguilar, James | last post by:
Hello all, To begin, yes, this -is- a homework assignment. However, it is for my Algorithms class, and my instructor has given us explicit permission to use "expert" groups like newsgroups, so...
2
by: James | last post by:
Hi, I am using Visual C++ 6.0. I got a "stack overflow" error message when running the program because of a "double array". I have a computer with 1GB memory. Can I extend the memory for the...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
4
by: Victor | last post by:
Hello, I've got a situation in which the number of (valid) recursive calls I make will cause stack overflow. I can use getrlimit (and setrlimit) to test (and set) my current stack size. ...
24
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
7
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char...
3
by: jack113256 | last post by:
Hi everyone: I have a question in using Callback function, there is my code: /******* code start *********/ #include <stdio.h> void a(); void b(); void run();
87
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.