473,516 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do we find out stepping over somebody else' memory

There are several occations where we write onto someone else' memory
region. Is there any debugging mechanism to find out which part of the
code is causing this problem?

Dec 8 '05 #1
5 1464
NewToCPP wrote:
There are several occations where we write onto someone else' memory
region. Is there any debugging mechanism to find out which part of the
code is causing this problem?


i am not sure what you mean by "someone else'" memory.

if you mean writing foreign process memory that should be easy to
detect in any debugger as the operating system protects such access
violations. any debugger should break at the offending statement.

on the other hand, if you thought about writing into your own memory
off bounds, eg. by overflowing an array or writing into freed memory,
you will have to use tools that enable memory bounds checking. with
such a tool any debugger should provide the same method as above by
breaking at offending statements.

examples are efence for linux
(http://perens.com/FreeSoftware/ElectricFence/) or the page heap
verification mechanism in windows (gflags.exe).

-- peter

Dec 8 '05 #2

NewToCPP wrote:
There are several occations where we write onto someone else' memory
region. Is there any debugging mechanism to find out which part of the
code is causing this problem?


You've started three threads today all about tracking down dynamic
memory bugs. In one of those other threads, someone suggested avoiding
all direct management of memory by using classes that do it for you.
std::vector or another container for collections of objects. Smart
pointers (std::auto_ptr where appropriate, or maybe something from
boost) for single objects. std::string instead of arrays of char. RAII
techniques. And, importantly, only dynamically allocating memory (even
when using classes designed for the purpose) when automatic storage
duration isn't sufficient.

This really is the single biggest step you can take towards avoiding
these bugs. It will be an easy step to take from this moment on with
any new code you write, a harder step to take when maintaining existing
code.

I know I haven't answered your particular question here (I'm not sure
what you mean by "someone else's memory" - another process, another
object in your program, or what?). But I wanted to reiterate the point
that, when you must use dynamic memory, use classes designed to take
the risks away.

Gavin Deane

Dec 8 '05 #3
Here I was referring to memory created by another object in the same
program. For example some memory created by different task (or thread)
in the same program.

Dec 8 '05 #4
NewToCPP wrote:
Here I was referring to memory created by another object in the same
program. For example some memory created by different task (or thread)
in the same program.


Then definitely follow my advice from the other thread. Use standard
containers. Pick an appropriate smart pointer and use it. Use
std::string. Create objects rather than pointers to objects whenever
possible.

If you're worried about threading, then the stock answer is that the C++
Standard doesn't address threading.

That said, check the synchronization primitives (mutexes, events,
critical sections, condition variables) that your platform provides, and
use them to protect your data structures in when necessary.

For further details on synchronization primitives, ask in a newsgroup
dedicated to your platform.
Dec 9 '05 #5
Thanks.

Dec 9 '05 #6

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

Similar topics

4
3836
by: Greg Baker | last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to post code and ask for help? I hope so.. :) Here's my problem: I am trying problem 127 of the valladolid online contests (http://online-judge.uva.es/p/v1/127.html). The program I wrote seems to work fine, but it takes way too much memory to run. I am not that...
3
13563
by: Rich | last post by:
Hello, If my datagrid is based on a dataTable (t1) and the currency manager is also bound to t1 and I do a find on a key dim dRow As DataRow, t1 As DataTable .... dRow = t1.Rows.find(somekey) If Not dRow Is Nothing
5
3072
by: scl | last post by:
I have an application with a .Net front end that makes calls into a series of VB6 dll's via COm InterOpt. Although everything works quite well, the main issue that I have is regarding the overall debugging workflow. Ideally, I would like to configure my IDE's such that when I am stepping through my .Net code that makes a call to a VB6 dll...
4
2059
by: comp.lang.php | last post by:
I downloaded the tarball and while was able to compile within PHP with no problems, I am having memory timeout issues involving image manipulation with extremely large images (800K - 2mb). Requirements are to create thumbnails for even these banner-sized images, but PHP + GD + = too much memory. I'm trying to prove that it is undoable,...
7
5098
by: david wolf | last post by:
I have a problem that is used to test memory leak as follows, however, after each run of the program, if I am using the command "free" on the linux box, I did not see any difference about the usable memory. My questions are: 1) How to find out exact free memory that my program can use? 2) Use which command to do this (top, or free) 3) why it...
7
1616
by: Lyn | last post by:
Is there a solution to this problem? While stepping through code (F8) it would sometimes be helpful to observe changes occurring on the affected form in the Access window. However, the current form always seems to be behind all of the open forms (including the Database window) and only small bits of it are visible -- depending on the sizes...
2
6640
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI Week5MortgageLogic allint = logic.allInterest(amount, term, rate); Week5MortgageGUI.java:152:cannot find symbol...
9
1911
by: xiao | last post by:
It always dumped when I tried to run it... But it compiles OK. What I want to do is to do a test: Read information from a .dat file and then write it to another file. The original DAT file is like this : (very simple..........) 010001010110001101010101010101010101010101 #include<stdio.h>
9
3179
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9. <option>north</option> 10. <option>south</option>
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.