Home » Community » Coffee corner » Strange program crash
Strange program crash [message #39157] |
Wed, 20 February 2013 20:57  |
 |
deep
Messages: 267 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
I am facing strange program crash.
System windows 7 64 bits, UPP5800, MSC10,
Test code.
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
Image image;
#define MAX_COL 750
#define MAX_ROW 750
struct Node
{
struct Node *Header;
struct Node *Left;
struct Node *Right;
struct Node *Up;
struct Node *Down;
char IDName;
int IDNum;
} ;
struct Node Root;
struct Node Roots[MAX_COL];
char Data[MAX_COL][MAX_ROW];
// struct Node Matrix[MAX_COL][MAX_ROW];
void Paint(Draw& w) {
w.DrawRect(GetSize(), Cyan());
w.DrawImage(10, 10, image);
}
MyApp() {
ImageDraw iw(100, 40);
iw.Alpha().DrawRect(0, 0, 100, 40, GrayColor(0));
iw.Alpha().DrawEllipse(0, 0, 100, 40, GrayColor(255));
iw.DrawEllipse(0, 0, 100, 40, Yellow());
iw.DrawText(26, 10, "Image", Arial(16).Bold());
image = iw;
}
};
GUI_APP_MAIN
{
MyApp().Sizeable().Run();
}
This code runs ok.
When I uncomment line with struct Node Matrix[MAX_COL][MAX_ROW]; Program crashes on run.
Crash report
Problem signature:
Problem Event Name: APPCRASH
Application Name: Test1.exe
Application Version: 0.0.0.0
Application Timestamp: 51252483
Fault Module Name: Test1.exe
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 51252483
Exception Code: c00000fd
Exception Offset: 002c4207
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 2057
Additional Information 1: 3a6e
Additional Information 2: 3a6e02c22fcc91129d3773f5deb0f79b
Additional Information 3: 39ad
Additional Information 4: 39ad623814f92b971a57f1c746b1a539
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
What can be the mistake ?
Warm Regards
Deepak
|
|
|
|
|
Re: Strange program crash [message #39177 is a reply to message #39176] |
Sat, 23 February 2013 05:06   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
code in c
struct node *RowHeader[MAX_ROW];
more likely translates to
typedef struct node Node;
// actually, in C you need the struct, in
// c++, it can be opted out
// so
// typedef node Node;
// is the same
Vector<Node*> RootHeader;
However, you may want to put the dynamically allocated node* into some smart pointer so that they will be delete'd (free'd).
or you can do it yourself
class MyNodeContainer : public Vector<node*>
{
public:
~MyNodeContainer()
{
for(int i=0; i<GetCount(); ++i)
delete (*this)[i];
// or free((*this)[i]); if the nodes are malloc'ed
}
and other method, eg, constructors,..
}
[Updated on: Sat, 23 February 2013 05:29] Report message to a moderator
|
|
|
|
Re: Strange program crash [message #39179 is a reply to message #39178] |
Sat, 23 February 2013 05:25  |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Vector<Node> *RootHeader;
Here RootHeader is a pointer to a Vector<Node> object. eg.
Vector<Node> nodes;
Vector<Node>* RootHeader=&nodes;
//or
Vector<Node>* p=new Vector<Node>();
while
Vector<Node*> RootHeader;
// here on the other hand, RootHeader if a Vector of pointer to Node objects. Vector can be thought of as dynamic array.
|
|
|
Goto Forum:
Current Time: Fri May 02 07:31:02 CEST 2025
Total time taken to generate the page: 0.03209 seconds
|