473,804 Members | 4,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

debugging a memory violation problem

I have probably "bitten off more than I can chew". But, I'm new to c++
and am trying to debug a program consisting of 9 files and about 2000
lines of code.

My program compiles but I get a runtime error: "Access violation:
segmentation fault raised in your program" -- dev c++ compiler.

Here is the most specific indicator of what is going wrong: There
follows a small sample of code.
From the screen displays, I see that node_number is at 10 (the value I

want) but that k is only displayed for its first two values of 0 and 1.

The functions set_equity and set_probability are fairly complex
recursive functions.

Can anyone speculate as to where the problem might lie? Does this
sound like a problem with a destructor?

Of course, I could provide more code but the full program is too long
to be appropriate so I don't know what else to include.

node_array = new node* [node_number];

for (int k = 0; k < node_number; k++)

{ cout << endl << node_number << node_number << node_number;
cout << endl << k << k << k << k;
debug << endl << "index " << k;

node_array[k] =
new node
(params, x_coord(params, k), y_coord(params, k),
rights_coord(pa rams, k));

node_array[k]-> set_equity();
node_array[k]-> set_probability ();

// more code

Thank you,

Paul Epstein

Jan 14 '06 #1
2 3455
TB
pa**********@at t.net sade:
I have probably "bitten off more than I can chew". But, I'm new to c++
and am trying to debug a program consisting of 9 files and about 2000
lines of code.

My program compiles but I get a runtime error: "Access violation:
segmentation fault raised in your program" -- dev c++ compiler.

Use the debugger with breakpoints and step through the code until
it happens.
Here is the most specific indicator of what is going wrong: There
follows a small sample of code.
From the screen displays, I see that node_number is at 10 (the value I want) but that k is only displayed for its first two values of 0 and 1.


Then most likely the error occurs in code executed after '1' is printed.
The functions set_equity and set_probability are fairly complex
recursive functions.

That shouldn't stop you from diving right in and debug them.
Can anyone speculate as to where the problem might lie? Does this
sound like a problem with a destructor?

Which destructor?
Of course, I could provide more code but the full program is too long
to be appropriate so I don't know what else to include.

node_array = new node* [node_number];

for (int k = 0; k < node_number; k++)

{ cout << endl << node_number << node_number << node_number;
cout << endl << k << k << k << k;
debug << endl << "index " << k;

node_array[k] =
new node
(params, x_coord(params, k), y_coord(params, k),
rights_coord(pa rams, k));

node_array[k]-> set_equity();
node_array[k]-> set_probability ();


So these two member functions should be your primary target, concidering
how little code who posted. And the functions 'x_coord' and 'y_coord',
as well as the constructor of 'node'. Trace and isolate the problem. We
cannot speculate and guess what your code looks like to find a problem.

TB
Jan 14 '06 #2
In article <11************ **********@g47g 2000cwa.googleg roups.com>,
pa**********@at t.net wrote:
I have probably "bitten off more than I can chew". But, I'm new to c++
and am trying to debug a program consisting of 9 files and about 2000
lines of code.

My program compiles but I get a runtime error: "Access violation:
segmentation fault raised in your program" -- dev c++ compiler.

Here is the most specific indicator of what is going wrong: There
follows a small sample of code.
From the screen displays, I see that node_number is at 10 (the value I want) but that k is only displayed for its first two values of 0 and 1.

The functions set_equity and set_probability are fairly complex
recursive functions.

Can anyone speculate as to where the problem might lie? Does this
sound like a problem with a destructor?


I don't see how this could be a destructor problem since no destructor
is called from within this code segment (if one is, then the code
calling it is at error.)
Of course, I could provide more code but the full program is too long
to be appropriate so I don't know what else to include.
One of the functions called in this code is accessing invalid memory.
Your going to have to step into the offending function until you find
the problem.

node_array = new node* [node_number];

for (int k = 0; k < node_number; k++)

{ cout << endl << node_number << node_number << node_number;
cout << endl << k << k << k << k;
debug << endl << "index " << k;

node_array[k] =
new node
(params, x_coord(params, k), y_coord(params, k),
rights_coord(pa rams, k));

node_array[k]-> set_equity();
node_array[k]-> set_probability ();

// more code

Thank you,

Paul Epstein


--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Jan 15 '06 #3

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

Similar topics

11
3811
by: Gustavo Franco | last post by:
Hi, I did a medium complex application in C#, and in some areas the memory goes up to 60Mb, when I finish I dispose everything and setting everything to null and calling GC.Collect, but the memory never goes below 45MB and I'm pretty sure I'm not allocating that huge amount of memory.
1
2468
by: BillyO | last post by:
In the attached code fragment I have a buffer overflow and a memory access violation. When I run the code .Net fails to verify the IL because of the buffer overflow and I get an exception as expected. My question relates to the memory access violation, specfically, what should happen? My guess is that since the good ole new operator allocates the memory we get an SEH memory access violation exception. Given that this can occur in my...
1
1771
by: Jason Smith | last post by:
I'm rather new with vb.net and I'm having problems debugging a large vb.net application. The application is randomly crashing at two locations with "referenced memory at 0x0" violations. My try-catch blocks are not trapping these exceptions. Sysinternals' procexp places the two crash addresses in ntdll.dll, offsets 2a84 and 2b6a - both in RtlLogStackBackTrace.
4
1573
by: pauldepstein | last post by:
I am writing code to price some financial options using recursive functions. It compiles but I get a runtime error which is caused by a memory violation. The problem is that the code is much too long to be suitable for inclusion in this posting, and I don't know where the problem lies. If anyone does have the time/willingness/extreme kindness to help me, I
1
2382
by: pauldepstein | last post by:
I am trying to debug a program with the Bloodshed dev c++ compiler. The program tries to use a recursive function to price financial options. It compiles but I get a memory violation when I run it. When I run it through the debugger, using watch variables, ofstream tritree_basic("tritree_basic_data.txt",
6
1564
by: bob | last post by:
hi, I have a question I should know the answer to. I've delivered a working set of c++ libraries/dlls that have been fully tested and validated. Now my problem is that somebody else has been furiously fixing memory leaks and what not in another DLL that is used by my own. I suddenly find myself in the situation where MY dll's are now crashing out and I'm fairly sure, that the fixes in the other DLL have hosed my stuff. I'm thinking...
8
2154
by: Brian | last post by:
What's the best way to debug code that is being run during garbage collection? We are getting AccessViolationExceptions that seem to be happening during garbage collection. But when it hits the debugger, it is at whatever line of code the main thread was at when the garbage collector decided to run. In other words, the debugger is in irrelevant code. In general, if you have bugs in Dispose or finalization methods, what's the best...
6
5581
by: nmehring | last post by:
I have an MFC app with 2000 users. I have one user that experiences a crash in our software anywhere from 1 to 5 times a week when opening a particular module. No other users have reported this particular crash so I don't think anyone else is experiencing it but I know other users are doing exactly what she is doing because it is our most popular module. I have analyzed the dmp files from several of this user's crashes using windbg...
33
2892
by: fmassei | last post by:
Hello! I made a short piece of code that I find very useful for debugging, and I wanted to ask you if it is correct, somehow acceptable or if I simply reinvented the wheel. To deal with some bad bugs caused by memory leaks I ended up with this simple solution: I made one header file that, when included, replaces the malloc/calloc/realloc/free functions with some other functions that do the actual job and insert (or remove) the pointers to...
0
9707
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
9585
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
10586
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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...
1
7622
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
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
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.