Discussion:
Debugger Exception Notification
(too old to reply)
Penny hapeny
2008-01-16 14:34:31 UTC
Permalink
Hi I hope some of you can help me.
I am using Builder 6 standard and trying to learn C++ by attempting to write
a program to solve a Sudoku puzzle.
The following code is one of the routines in my program Grid[Row][Col][box]
is a three dimensional array
the first position in this array that I have called [box] here just for
clarity, contains the value where that is given at the start of the game.
If that value is zero then the following positions hold all the possible
solutions for that place on the Grid.
I have now added a button called Check_Singles2 this looks to see if any of
the predicted solutions give only one value, If this is
the case then I want to change the Font Color before entering that value
into the displayed Grid that consists of 9x9 Edit boxes. the color
originally when the given values were entered was Red. So the idea is that
by being Black one can see what has been entered at this stage.
The program compiles Ok but when Run produces the error shown lower down at
the point in the code that Builder indicates.

Later runs of the same program without any modification have only produced
the second message.

void __fastcall TForm1::Check_Singles2Click(TObject *Sender)
{
{//1 Open
bool Flag = false;
Row =0;
Col =0;
x = 1;
/*** This routine will be to find if there is only a single possibility and
if so enter it into that box, with a Black character font
***********/

/**** Checks if box contains a given value and set a flag
****/
if(Grid[Row][Col][0] != 0)
Flag = true; // If true set Flag true else false.
else Flag = false;

if(Flag == false) // If false do the following code. If true skip
following code.

{//2 Open
for(Row =0; Row <=9; Row++)
{//3 Open
for(Col =0; Col <=9; Col++)
{//4 Open
if((Grid[Row][Col][x] >> Grid[Row][Col][x+1]) &&
(Grid[Row][Col][x+1] == 0))
{//5 Open
// There is only one possible value.
Grid[Row][Col][0] = Grid[Row][Col][1]; // So copy it to the first
position in Grid
Grid[Row][Col][1] = 0; // And replace the value in
the second position with a zero.
TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now
change the Font Color to Black. But a Run error here.
With the above line of code highlighted.

Debugger Exception Notification
---------------------------
Project Project_024.exe raised exception class EAccessViolation with message
'Access violation at address 004049EC in module 'Project_022.exe'.
Read of address 00000069'. Process stopped. Use Step or Run to continue.

If I then pressed F9 (Run) at this point, I got the following message.
---------------------------

Access violation at address 004050E8 in module 'Project_024.exe'. Read of
address 00000069.
---------------------------
OK

Clicking OK and the program continues to run and the digits entered by this
function are now in Black.

EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box

}//5 Close
}//4 Open
}//3 Close
}//2 Close
}//1 Close

}

Thanks hoping for some help
Penny.
Asger Joergensen
2008-01-16 15:31:38 UTC
Permalink
Hi Penny

this line:

if((Grid[Row][Col][x] >> Grid[Row][Col][x+1]) && (Grid[Row][Col][x+1] == 0))

looks suspicious whats with the >>
(dont You get a warning ?)

And then try and put in a breakpoint right before the error
and then see what the values of Row and Col are to make sure
they stay within bounds.

It would be nice to see how You declare the Grid
what type Grid[How many][How many][How many]

p.s.You can write like this:
Flag = Grid[Row][Col][0] != 0;

Kind regards
Asger
Penny hapeny
2008-01-16 16:01:23 UTC
Permalink
Hi Asger
Post by Asger Joergensen
Hi Penny
if((Grid[Row][Col][x] >> Grid[Row][Col][x+1]) && (Grid[Row][Col][x+1] == 0))
looks suspicious whats with the >>
(dont You get a warning ?)
No I havn't had a warning about this. If I delete one of the > (greater
than) it Compiles and runs as before.
Post by Asger Joergensen
And then try and put in a breakpoint right before the error
and then see what the values of Row and Col are to make sure
they stay within bounds.
With Break points at the following 3 lines
Grid[Row][Col][1] = 0; // And replace the value in
the second position with a zero.

TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now change
the Font Color to Black. But a Run error here. F9 continues past the error.
EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box

The Program still Runs as before and only with the second error message as I
had stated previously, but the program never stops at the break points.
If I add a Break Point at the start of this function also, then it still
doesn't stop. I see the error message, and behind it I can see that the
values displayed in a Black Font are shown, suggesting that the function has
run. I wonder if the Error Message being displayed and being in Focus has
prevented the Break Points from stoping the program.
Post by Asger Joergensen
It would be nice to see how You declare the Grid
what type Grid[How many][How many][How many]
In my Header file I have the following
public: // User declarations
int Grid[9][9][11];
Post by Asger Joergensen
Flag = Grid[Row][Col][0] != 0;
Kind regards
Asger
Thanks more help needed.
Penny
Asger Joergensen
2008-01-16 16:17:46 UTC
Permalink
Hi Penny
Post by Penny hapeny
Hi Asger
TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now change
the Font Color to Black. But a Run error here. F9 continues past the error.
EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box
You dont need the TForm1:: when You are inside the class.
Post by Penny hapeny
The Program still Runs as before and only with the second error message as I
had stated previously, but the program never stops at the break points.
If I add a Break Point at the start of this function also, then it still
doesn't stop. I see the error message, and behind it I can see that the
values displayed in a Black Font are shown, suggesting that the function has
run. I wonder if the Error Message being displayed and being in Focus has
prevented the Break Points from stoping the program.
If You set the break at the start of the function it should stop
unless the error occur before the function is called.

Maybe You are not running in full debug mode ?

Menu: Project->Options Tab:Compilor Button[Full Debug]

Kind regards
Asger
Penny hapeny
2008-01-16 16:36:49 UTC
Permalink
Hi Asger
Post by Asger Joergensen
Hi Penny
Post by Penny hapeny
Hi Asger
TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now change
the Font Color to Black. But a Run error here. F9 continues past the error.
EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box
You dont need the TForm1:: when You are inside the class.
No it just got added when debugging at some time and didn't get removed.
Post by Asger Joergensen
Post by Penny hapeny
The Program still Runs as before and only with the second error message as I
had stated previously, but the program never stops at the break points.
If I add a Break Point at the start of this function also, then it still
doesn't stop. I see the error message, and behind it I can see that the
values displayed in a Black Font are shown, suggesting that the function has
run. I wonder if the Error Message being displayed and being in Focus has
prevented the Break Points from stoping the program.
If You set the break at the start of the function it should stop
unless the error occur before the function is called.
Maybe You are not running in full debug mode ?
Menu: Project->Options Tab:Compilor Button[Full Debug]
I have checked this and with a Break Point at the start of the function, I
still have the same IE Error Message and Black digits entered where expected
but no Break in the Program.
As you say perhaps the fault is else where, but if so would you have
expected the result of this function to have performed.
Post by Asger Joergensen
Kind regards
Asger
Kind Regards
Penny
Penny hapeny
2008-01-16 17:16:41 UTC
Permalink
Hi Asger

Since my last reply I have been experimenting with earlier versions of my
program, putting Break Points in, but none of them seem to stop the program.
I wonder if my version of Builder has become corrupted. I will have to
re-install it and see, but that will be an exercise for another day now.

Kind Regards
Penny
Post by Penny hapeny
Hi Asger
Post by Asger Joergensen
Hi Penny
Post by Penny hapeny
Hi Asger
TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now change
the Font Color to Black. But a Run error here. F9 continues past the error.
EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box
You dont need the TForm1:: when You are inside the class.
No it just got added when debugging at some time and didn't get removed.
Post by Asger Joergensen
Post by Penny hapeny
The Program still Runs as before and only with the second error message as I
had stated previously, but the program never stops at the break points.
If I add a Break Point at the start of this function also, then it still
doesn't stop. I see the error message, and behind it I can see that the
values displayed in a Black Font are shown, suggesting that the function has
run. I wonder if the Error Message being displayed and being in Focus has
prevented the Break Points from stoping the program.
If You set the break at the start of the function it should stop
unless the error occur before the function is called.
Maybe You are not running in full debug mode ?
Menu: Project->Options Tab:Compilor Button[Full Debug]
I have checked this and with a Break Point at the start of the function, I
still have the same IE Error Message and Black digits entered where
expected but no Break in the Program.
As you say perhaps the fault is else where, but if so would you have
expected the result of this function to have performed.
Post by Asger Joergensen
Kind regards
Asger
Kind Regards
Penny
Penny hapeny
2008-01-17 15:53:23 UTC
Permalink
Hi Asger,
I have now reinstalled Builder, and the Break Points now work.
I have set up several Break Points in the function and copied the Watch List
that I have created to a text file.
After several passes through the loops, I have the original two error
messages back.
This time I have gone back and studied the Watch List at each Break Point,
comparing the data with the Program.
The interesting details as follows

BP3
Grid[Row][Col][1]: 0
EditControls[Row][Col]->Font->Color: ????
EditControls[Row][Col]->Text: E2122 Function call terminated by unhandled
exception 0xc0000005 at address 0x401075b9
IntToStr (Grid[Row][Col][0]): E2382 Side effects are not allowed
Row: 9
Col: 0
x: 1
if((Grid[Row][Col][x] > Grid[Row][Col][x+1]) && (Grid[Row][Col][x+1] == 0)):
E2188 Expression syntax

Row has got to 9 and this is where the problem lies, although there are 9
rows they start at 0 up to 8
so correcting my for(statements) has resolved the problem.

Thanks for your guidance that has lead me to it.

Regards Penny.
Post by Penny hapeny
Hi Asger
Since my last reply I have been experimenting with earlier versions of my
program, putting Break Points in, but none of them seem to stop the
program. I wonder if my version of Builder has become corrupted. I will
have to re-install it and see, but that will be an exercise for another
day now.
Kind Regards
Penny
Post by Penny hapeny
Hi Asger
Post by Asger Joergensen
Hi Penny
Post by Penny hapeny
Hi Asger
TForm1::EditControls[Row][Col]->Font->Color = clBlack; // Now change
the Font Color to Black. But a Run error here. F9 continues past the error.
EditControls[Row][Col]->Text = IntToStr (Grid[Row][Col][0]); // Show
the value in the Edit Box
You dont need the TForm1:: when You are inside the class.
No it just got added when debugging at some time and didn't get removed.
Post by Asger Joergensen
Post by Penny hapeny
The Program still Runs as before and only with the second error message as I
had stated previously, but the program never stops at the break points.
If I add a Break Point at the start of this function also, then it still
doesn't stop. I see the error message, and behind it I can see that the
values displayed in a Black Font are shown, suggesting that the function has
run. I wonder if the Error Message being displayed and being in Focus has
prevented the Break Points from stoping the program.
If You set the break at the start of the function it should stop
unless the error occur before the function is called.
Maybe You are not running in full debug mode ?
Menu: Project->Options Tab:Compilor Button[Full Debug]
I have checked this and with a Break Point at the start of the function,
I still have the same IE Error Message and Black digits entered where
expected but no Break in the Program.
As you say perhaps the fault is else where, but if so would you have
expected the result of this function to have performed.
Post by Asger Joergensen
Kind regards
Asger
Kind Regards
Penny
Continue reading on narkive:
Loading...