Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ Unhandled exception at 0x00000000

Reply
Thread Tools

C++ Unhandled exception at 0x00000000

 
 
AMT2K5
Guest
Posts: n/a
 
      11-27-2005
Hello, I am trying to figure out the source of this unhandled exception
(bad pointer or unallocated memory)

I have a parent class, IOField with the following pointer to function

bool (*isValid)(void *data, IOScreen *scrPtr);

This holds the address of a function that is desinged to validate the
data of an IOField after being edited. The IOField is displayed in an
IOSCreen pointed by "scrPtr".

Now later on in a child class, I want to make a function call to
isValid;

if(isValid(data,this->owner) == false) condition = true;

Previous functions allocate memory for data and store strings in them,
and this->owner is set in the constructor.

data and, this->owner has an address but isValid does not.

When compiling, the only address with 0x00000000 is isValid;

Visual Studio 2005 reports,
data 0x00129ac8 void *
+ owner 0x0012920c {fnum=15 row=2 col=5 ...}
IOScreen *
isValid 0x00000000 bool (void *, IOScreen *)*
+ this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
IOLineEdit * const

Maybe I am doing something wrong with pointer to functions, I dont have
*that* much experience using them (they are required in this college
assignment).

Appreciate any help and thanks in advance.

 
Reply With Quote
 
 
 
 
Artie Gold
Guest
Posts: n/a
 
      11-27-2005
AMT2K5 wrote:
> Hello, I am trying to figure out the source of this unhandled exception
> (bad pointer or unallocated memory)
>
> I have a parent class, IOField with the following pointer to function
>
> bool (*isValid)(void *data, IOScreen *scrPtr);
>
> This holds the address of a function that is desinged to validate the
> data of an IOField after being edited. The IOField is displayed in an
> IOSCreen pointed by "scrPtr".
>
> Now later on in a child class, I want to make a function call to
> isValid;
>
> if(isValid(data,this->owner) == false) condition = true;
>
> Previous functions allocate memory for data and store strings in them,
> and this->owner is set in the constructor.
>
> data and, this->owner has an address but isValid does not.
>
> When compiling, the only address with 0x00000000 is isValid;
>
> Visual Studio 2005 reports,
> data 0x00129ac8 void *
> + owner 0x0012920c {fnum=15 row=2 col=5 ...}
> IOScreen *
> isValid 0x00000000 bool (void *, IOScreen *)*
> + this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
> IOLineEdit * const
>
> Maybe I am doing something wrong with pointer to functions, I dont have
> *that* much experience using them (they are required in this college
> assignment).
>
> Appreciate any help and thanks in advance.
>

Have you initialized/assigned a value to `isValid'? (It sure looks like
you haven't.)

Show us the constructors for your class and we might be able to help.

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
 
Reply With Quote
 
 
 
 
AMT2K5
Guest
Posts: n/a
 
      11-27-2005
IOField::IOField(int row, int col,void (*help)(IOScreen *), bool
(*isValid)(void *, IOScreen *)):Ok(true){
this->row = row;
this->col = col;
this->help = help;
this->isValid = isValid;
this->data = NULL;
setOwner(NULL);
}



IOLineEdit::IOLineEdit(int row, int col, int flen, int slen, int *ins,
void (*help)(IOScreen *), bool (*isValid)(void *, IOScreen *)
):IOField(row,col,help,isValid){
Ok = false;
data = new char[slen+1];
if(data){
Ok = true;
dynamic = true;
curpos = spos = 0;
this->flen = flen;
this->slen = slen;
this->ins = ins;
((char*)data)[0] = 0;
}
}

 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      11-27-2005
AMT2K5 wrote:
> Hello, I am trying to figure out the source of this unhandled exception
> (bad pointer or unallocated memory)
>
> I have a parent class, IOField with the following pointer to function
>
> bool (*isValid)(void *data, IOScreen *scrPtr);
>
> This holds the address of a function that is desinged to validate the
> data of an IOField after being edited. The IOField is displayed in an
> IOSCreen pointed by "scrPtr".
>
> Now later on in a child class, I want to make a function call to
> isValid;
>
> if(isValid(data,this->owner) == false) condition = true;
>
> Previous functions allocate memory for data and store strings in them,
> and this->owner is set in the constructor.
>
> data and, this->owner has an address but isValid does not.
>
> When compiling, the only address with 0x00000000 is isValid;
>
> Visual Studio 2005 reports,
> data 0x00129ac8 void *
> + owner 0x0012920c {fnum=15 row=2 col=5 ...}
> IOScreen *
> isValid 0x00000000 bool (void *, IOScreen *)*
> + this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
> IOLineEdit * const
>
> Maybe I am doing something wrong with pointer to functions, I dont have
> *that* much experience using them (they are required in this college
> assignment).
>
> Appreciate any help and thanks in advance.
>


Well nowhere in this descrption have you said where you assign an
address to isValid. Also judging by your debugger output isValid has an
address of NULL. Is it possible you just forgot to assign an address to
isValid?

If this doesn't help then remove all extraneous code from your program,
so that you have a small but still compilable program which still has
this problem, then post the entire code here. It's difficult to solve
coding problems without seeing the code.

john
 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      11-27-2005
AMT2K5 wrote:
> IOField::IOField(int row, int col,void (*help)(IOScreen *), bool
> (*isValid)(void *, IOScreen *)):Ok(true){
> this->row = row;
> this->col = col;
> this->help = help;
> this->isValid = isValid;
> this->data = NULL;
> setOwner(NULL);
> }
>
>
>
> IOLineEdit::IOLineEdit(int row, int col, int flen, int slen, int *ins,
> void (*help)(IOScreen *), bool (*isValid)(void *, IOScreen *)
> ):IOField(row,col,help,isValid){
> Ok = false;
> data = new char[slen+1];
> if(data){
> Ok = true;
> dynamic = true;
> curpos = spos = 0;
> this->flen = flen;
> this->slen = slen;
> this->ins = ins;
> ((char*)data)[0] = 0;
> }
> }
>


Well there is nothing wrong with that code. But somewhere in your
program you have a bug. This could take a while.

Please have a look at the guidelines for posting code

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Follow those recommendations and you'll have a solution very quickly

john
 
Reply With Quote
 
AMT2K5
Guest
Posts: n/a
 
      11-27-2005
I see how isValid is NULL which I dont understand since I set it in the
parent constructor

this->isValid = isValid

 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      11-27-2005
"AMT2K5" <> wrote in message
news: oups.com...
>I see how isValid is NULL which I dont understand since I set it in the
> parent constructor
>
> this->isValid = isValid
>


Yes, but you are assuming that the isValid passed in isn't null.

Put a debug break on that line.

Then debug the program. What is the value of the isValid you are passing
in? I'll bet you it's null.


 
Reply With Quote
 
AMT2K5
Guest
Posts: n/a
 
      11-27-2005
Correct, yes it is.

 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      11-27-2005
"AMT2K5" <> wrote in message
news: oups.com...
> Correct, yes it is.
>


Well, so now you know your problem, right? You're passing null in. Find
out where you're passing it in, and find out why you're passing null.


 
Reply With Quote
 
AMT2K5
Guest
Posts: n/a
 
      11-27-2005
Trying to understand what you said, I think the problem lies within the
= NULL defaults im using in the class definition?

public:
IOLineEdit( char *str, int row, int col, int flen, int slen,
int *ins = NULL, void (*help)(IOScreen *) = NULL,
bool (*isValid)(void *, IOScreen *) = NULL);
IOLineEdit(int row, int col, int flen, int slen, int *ins = NULL,
void (*help)(IOScreen *) = NULL,
bool (*isValid)(void *, IOScreen *) = NULL);

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WindowsError: exception: access violation writing 0x00000000 Sparky Python 3 08-04-2009 05:23 PM
The exception unknown software exception (0xc0000409) occurred in the application at location 0x00000000. Lars-Erik Aabech ASP .Net 7 05-19-2009 08:04 PM
an unhandled win32 exception was unhandled occurred in inetinfo.exe Warren Tang ASP .Net 1 09-23-2008 03:01 PM
An unhandled exception has been caught by the VSW exception filter. Tedka ASP .Net 2 07-19-2004 08:09 PM
An unhandled exception has been caught by the VSW exception filter. Ola ASP .Net 0 04-26-2004 01:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57