473,811 Members | 2,685 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 1485
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
3855
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 good at programming C++, unfortunately, so I can't seem to find my memory leak. As far as I can tell,...
3
13578
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
3092
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 method, I am able to step into the VB6 IDE to continue the debugging process. Currently, I cannot...
4
2074
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, though the suggestion was to do a command-line GD call to the image instead of using the PHP...
7
5113
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 does not show memory leak in my case (I am using the linux command free) ...
7
1627
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 and locations of the various forms on the screen. Is there a way to ensure that the form being...
2
6667
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 symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI
9
1936
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
3209
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
9727
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10133
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6889
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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
2
3865
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.