Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Sun May 09, 2010 5:56 pm   

[3.16b] Duplicating variables
 
I sometimes get an exception from CMUD probably because a variable is duplicated. Well, that is my best guess anyway as I often see this when I get an exception. Problem is that I don't know exactly how the duplicate was created. The duplicates are always created at the root, I never try to create the variable but I often do a "variable = something" operation. However this is always done in a section and allways with the same name so there should be no problem.

I think there is something vulnerable in the code or I'd like to hear good advice about how to avoid the problem. Thanks.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun May 09, 2010 8:06 pm   
 
if the variable was in a class that was disabled it would be unseen and a new var gets created
_________________
Discord: Shalimarwildcat
Reply with quote
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Sun May 09, 2010 8:59 pm   
 
It isn't though.

I have a variable called commandQueue. This is used here:

Code:

...
#SECTION commandQueueSection {
  commandQueue = %push($commandItem, @commandQueue)
}
...


and here:

Code:

...
#SECTION commandQueueSection {
  $commandItem = %pop(commandQueue)
}
...


and here:

Code:

...
#SECTION commandQueueSection {
  $result = (%numitems(@commandQueue) = 0)
}
...


and finally here:

Code:

...
#SECTION commandQueueSection {
  commandQueue = %additem($queueItem, @commandQueue)
}
...


No other places and no disable classes.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun May 09, 2010 11:45 pm   
 
You're absolutely certain that there is no other piece of code trying to set @commandQueue? It looks like you have it handled correctly. Are all of the scripts that refer to @commandQueue in the same package? Is @commandQueue defined in the same package or a different one? Is the duplicate variable appearing in the same package as the scripts?

It looks like you have done the right things (assuming the answers I expect to the above questions). If you do have it set up correctly, it should be working fine. There have been reports of spurious duplicated variables before, but most cases were tracked down to one of: the variable or its class being disabled; a script defined in a package or window where it could not see the correct variable; or a script they forgot about creating the duplicate variable. A few cases have not been fully explained, perhaps due to insufficient information. No one has been able to show a repeatable procedure that created a duplicate variable when it shouldn't have. I suggest you a) double check all your code to see that every instance of @commandQueue is handled correctly, and b) try to find a repeatable procedure that creates the duplicate. Most likely that will simply identify a problem in your code, but it is always possible that there is a bug in Cmud. If so, a repeatable procedure is necessary before it can be fixed.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon May 10, 2010 2:55 am   
 
I'm almost convinced it might be a threading issue. Why do I suppose that? Because recently I added a #WAIT to force a threading of my email script. Ever since that day, I've had two variables duplicate itself to the root folder. Never realized it until just now, though.

Charneus
Reply with quote
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Mon May 10, 2010 5:39 pm   
 
Rahab wrote:
You're absolutely certain that there is no other piece of code trying to set @commandQueue? It looks like you have it handled correctly. Are all of the scripts that refer to @commandQueue in the same package? Is @commandQueue defined in the same package or a different one? Is the duplicate variable appearing in the same package as the scripts?

It looks like you have done the right things (assuming the answers I expect to the above questions). If you do have it set up correctly, it should be working fine. There have been reports of spurious duplicated variables before, but most cases were tracked down to one of: the variable or its class being disabled; a script defined in a package or window where it could not see the correct variable; or a script they forgot about creating the duplicate variable. A few cases have not been fully explained, perhaps due to insufficient information. No one has been able to show a repeatable procedure that created a duplicate variable when it shouldn't have. I suggest you a) double check all your code to see that every instance of @commandQueue is handled correctly, and b) try to find a repeatable procedure that creates the duplicate. Most likely that will simply identify a problem in your code, but it is always possible that there is a bug in Cmud. If so, a repeatable procedure is necessary before it can be fixed.

I searched for all uses of the variable and there really should be no other places where I use it. One of the pieces of code is called from another folder. Is that a problem? I have to split my code op somehow and I don't recall to have read that this should be a problem.

I get the bug once in a while but I cannot provoke it myself so it's hard to come up with an example that will duplicate the variable every time. I know that all code runs fine mostly but then once in a while generates a duplicate and I get a cough from CMUD...

EDIT: The duplicates are always created in the root which is logical as I don't fully qualify it anyway. However the original variables are placed in folders.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon May 10, 2010 5:54 pm   
 
In the above places where you show that you use the variable, where are these getting used? Are these in triggers, or aliases, or events, or functions, or what? If they are in triggers, then what class folder are the triggers in? Same folder as the variables? Or a different folder?

We need to see more details on your class structure layout and where this variable is being called to help with this.

Quote:
Because recently I added a #WAIT to force a threading of my email script. Ever since that day, I've had two variables duplicate itself to the root folder.

Then it sounds like you should be able to narrow that down to a simple test script that can be used to track down this error. #WAIT itself should not be causing any of this, especially in kjaerhus' case since he is properly using the #SECTION command to protect his variable.
Reply with quote
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Tue May 11, 2010 6:10 pm   
 
The first two pieces are from an alias in the same folder as the variable. The third is from a function in the same folder and the fourth and last piece of code is from an alias in another folder.

I can send in the full code if it's of any use.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 11, 2010 7:44 pm   
 
Is the folder containing the fourth piece of code in a different module or window from the others?
Reply with quote
kjaerhus
Magician


Joined: 18 Dec 2006
Posts: 317
Location: Denmark

PostPosted: Tue May 11, 2010 9:05 pm   
 
Same window.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net