int Property Problem - very odd indeed

W

wASP

Hi,

I've got a pair of int properties in a class.

The properties in question are indexing values
- but that's not relevant to my problem
- or it's just symptomatic ... sort of.

They are declared as follows:

public class obj_set_class
{
private int que_ndx;
private int stk_ndx;
..
..
..
}

It's pretty straight-forward - nothing out of the ordinary.

NOW for the problem ...

I was chasing after a bug, and, while I was stepping through
the method that uses one of those int properties (stk_ndx),
I execute a statement that increments that int property,
and the OTHER int property (que_ndx) gets incremented as well.

Again, it's pretty straight-forward:
stk_ndx += 1;

After this statement is executed, que_ndx gets incremented,
as well as stk_ndx.

My only speculation is that both int symbols are being
given the same address - which would be bizarre.

Has anyone got any idea as to what is causing this?
... and how to fix it?


THANKS!

- wASP
 
W

wASP

There are different member variables if that happens its magic.

... more like black magic - a curse - a hex (booooooo, sorry).


Honestly, I'm not being a troll - this is actually happening!

I step across the statement that increments the one int property,
and the BOTH of them get incremented (in the variables window).

<hearing theme music from The Twilight Zone>

- wASP
 
D

Damien

wASP said:
... more like black magic - a curse - a hex (booooooo, sorry).


Honestly, I'm not being a troll - this is actually happening!

I step across the statement that increments the one int property,
and the BOTH of them get incremented (in the variables window).
I'm a bit confused. Can we have a terminology check please? Are we
dealing with *variables* or *properties*. Properties are (generally)
small stubs of code which allow you to set or retrieve data internal to
a class. As such, the code can do anything it pleases. On the other
hand, variables are just storage places.

Your narrative doesn't seem to match up with the short code snippets
you've posted. Could you post the complete class? If not, can you post
just the relevant bits (variables, properties (if these exist) and the
chunk of code which is performing the update)? As is a popular saying
in some other groups - it's pretty difficult to debug code when you're
not allowed to look at it.

Finally, you're certain that both are incrementing - but do they both
have the same value or different values? If different, then they cannot
possibly be sharing the same place :)

Damien
 
M

Mr Newbie

Well now. We know this should not happen don't we, so what are we going to
do about your perplexing quandary?

My first idea would be to try and reproduce this in another project.

1.) Re-create your class and perform the += on the individual members and
debug, do you still have the predicament?

2.) If the answer to 1.) Is yes, then either you are insane or there is
something seriously wrong with your installation of visual studio and you
should try it on another computer.

3.) If the answer is no then re-create your project and see if it still
happens. If it does, you are insane and should book yourself into a clinic,
if not, then break out the champers and celebrate.

Seriously though, is there anything we don't know, like you have set up
DataBinding to these properties, and some firing event is making them equal?
(Just a shot in the dark)


HTH - :)

The Inimitable Mr Newbie......
 
M

Mr Newbie

Perhaps they can share the same space, but not in the same universe. He may
be suffering from a 25th/26th dimensional slip where in one dimension, he is
incrementing the first, and the second within the other and simply can't
distinguish those momentary slips from each other in a similar way that one
cannot distinguish the frames in a movie.

On the other hand, there is probably a far more earthly explanation.

:)

The Inimitable Mr Newbie . . .
 
W

wASP

UPDATE ...

OK - I had some unrelated stuff come up yesterday that
interrupted me and diverted my attention away from this problem,
and I didn't have much time to focus on it. I'm still trying stuff,
and my intention was to make a follow-up post with
the results that I got with everything that I've tried.

That process is still on-going - I've not yet exhausted all of my
alternatives. I made the initial post - starting this thread
- in the hopes that someone might have had a similar experience
to the one that I'm having - or have encountered this problem
before with someone else - and could give me a sweet and simple
explanation - along with a viable solution. I guess I was
hoping against hope on that one - but it doesn't hurt to ask.


First of all, I want to thank all of those who responded
- as always, I appreciate your input.


I want to thank those of you who corrected me on my terminology:
I meant integer *FIELDS* - not properties
- and I'm a big, fat, stoopid, poopoo-head for that gaffe
- I'm red-faced with embarrassment. <cringe>


With the time that I've spent on this, I've tried all kinds
of different stuff - and all kinds of strange things
have been happening.

For one, I tried creating a new FIELD in the class
- calling it que2_ndx
- leaving the old one in its place (que_ndx)
- and just assigning to it a value of 0
- and the same weird stuff is happening to the new FIELD
- to que2_ndx
- and the old FIELD (que_ndx) is untouched.

The one common denominator is that this particular indexing field
(que2_ndx) is used in a GET accessor - though that accessor
is not used in the method where the problem is manifesting itself.

I altered that GET accessor - tried commenting out a
conditional IF that makes reference to the indexing field
(which at first was called que_ndx but is now called que2_ndx)
- an IF statement that compares the values of the two:

// if (que2_ndx < stk_ndx)
que2_ndx++;

... and things got even MORE bizarre:
After compiling - with the conditional IF commented out
- instead of the indexing field que2_ndx being incremented
afer the execution of the instruction to increment the
indexing variable that the statement SHOULD increment (stk_ndx)
- the que2_ndx field now gets incremented after the execution
of a system function call that adds an object to an array list
- which is positioned BEFORE the instruction that increments
the stk_ndx.

I'm beginning to think that there's some kind of a glitch
in the accessor mechanism, and I'm considering the alternative
of rewriting the accessors - turning them into methods
- and eliminating the use of accessors altogether in the
class where I'm having this problem.

There is still some more stuff that I'm going to try
before this, however.

I'm not using visual studio in any of this,
so it isn't a factor.

I tried installing ASP.NET and IIS on another box,
ran this critter on that other system,
and I got the same behavior
- so this problem isn't unique to my particular system.

I'll post back later with my results.


THANKS AGAIN!


####################################################################

Hi,

I've got a pair of int properties in a class.

The properties in question are indexing values
- but that's not relevant to my problem
- or it's just symptomatic ... sort of.

They are declared as follows:

public class obj_set_class
{
private int que_ndx;
private int stk_ndx;
.
.
.
}

It's pretty straight-forward - nothing out of the ordinary.

NOW for the problem ...

I was chasing after a bug, and, while I was stepping through
the method that uses one of those int properties (stk_ndx),
I execute a statement that increments that int property,
and the OTHER int property (que_ndx) gets incremented as well.

Again, it's pretty straight-forward:
stk_ndx += 1;

After this statement is executed, que_ndx gets incremented,
as well as stk_ndx.

My only speculation is that both int symbols are being
given the same address - which would be bizarre.

Has anyone got any idea as to what is causing this?
... and how to fix it?


THANKS!

- wASP

- wASP
 
W

wASP

UPDATE ... AND RESOLUTION ...

OK - so I tried moving the indexing fields into another class,
then made it the base class to the class that the fields
were members of, set access to private for both integer fields,
then created GET and SET accessors to control access to the fields.

It didn't work.

The value for que_ndx was STILL being altered
whenever the value for stk_ndx was incremented.

The common denominator in this is that both of the indexing fields
are referenced in a member accessor for the main (derived) class.
I mentioned before that, whenever I commented out a conditional IF
statement that makes use of the que_ndx field, that there was
a change in behavior.

I THEN proceeded to alter those accessors (there were two
that used the fields) - turning them into methods - member functions.


IT WORKED!


HEY MICROSOFT: YOU HAVE A PROBLEM WITH ACCESSORS IN C#!


Moral of the story: Whenever you've got some weird shit
like that happening, suspect any accessors that you might
be using in the class. I know that this garbage caused me
a lot of grief - not to mention lost time.

I want to thank everyone who responded - your input is appreciated.

Later gang!

wASP
#################################################

Hi,

I've got a pair of int properties in a class.

The properties in question are indexing values
- but that's not relevant to my problem
- or it's just symptomatic ... sort of.

They are declared as follows:

public class obj_set_class
{
private int que_ndx;
private int stk_ndx;
.
.
.
}

It's pretty straight-forward - nothing out of the ordinary.

NOW for the problem ...

I was chasing after a bug, and, while I was stepping through
the method that uses one of those int properties (stk_ndx),
I execute a statement that increments that int property,
and the OTHER int property (que_ndx) gets incremented as well.

Again, it's pretty straight-forward:
stk_ndx += 1;

After this statement is executed, que_ndx gets incremented,
as well as stk_ndx.

My only speculation is that both int symbols are being
given the same address - which would be bizarre.

Has anyone got any idea as to what is causing this?
... and how to fix it?


THANKS!

- wASP

- wASP
 
W

wASP

Well now. We know this should not happen don't we, so what are we going to
do about your perplexing quandary?

You are correct: THIS should not happen - but it is - and my code isn't to blame.

My first idea would be to try and reproduce this in another project.

1.) Re-create your class and perform the += on the individual members and
debug, do you still have the predicament?

2.) If the answer to 1.) Is yes, then either you are insane or there is
something seriously wrong with your installation of visual studio and you
should try it on another computer.

I'm likely insane - but one of the causes is problems like this one.

3.) If the answer is no then re-create your project and see if it still
happens. If it does, you are insane and should book yourself into a clinic,
if not, then break out the champers and celebrate.

Seriously though, is there anything we don't know, like you have set up
DataBinding to these properties, and some firing event is making them equal?
(Just a shot in the dark)


HTH - :)

The Inimitable Mr Newbie......

Thanks for the response.

(Please see resolution post in this thread.)

<theme music from The Twilight Zone>


- wASP
 
W

wASP

I'm a bit confused. Can we have a terminology check please? Are we
dealing with *variables* or *properties*. Properties are (generally)
small stubs of code which allow you to set or retrieve data internal to
a class. As such, the code can do anything it pleases. On the other
hand, variables are just storage places.

variables - fields actually.

Thanks for setting me straight on that one - I'm a bit embarrassed.

Your narrative doesn't seem to match up with the short code snippets
you've posted. Could you post the complete class? If not, can you post
just the relevant bits (variables, properties (if these exist) and the
chunk of code which is performing the update)? As is a popular saying
in some other groups - it's pretty difficult to debug code when you're
not allowed to look at it.

Finally, you're certain that both are incrementing - but do they both
have the same value or different values? If different, then they cannot
possibly be sharing the same place :)

Damien

Same values - every time.

(Please see my resolution post in this thread.)

- wASP
 
M

Mr Newbie

Still a little unclear about this solution or (workaround), but top marks
for persevering with the issue. Thats whats set's someone like yourself
apart from the 'Great Unwashed', you kept at it until you resolved it.

Well Done !
 
W

wASP

Still a little unclear about this solution or (workaround), but top marks
for persevering with the issue. Thats whats set's someone like yourself
apart from the 'Great Unwashed', you kept at it until you resolved it.

Well Done !

Thanks - but my motivations aren't as noble as you make them out to be.

I was in a position where I absolutely MUST solve the problem
- or my entire project goes down the tubes.

It was more a matter of desperation than anything else.

- wASP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top