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
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Wed Dec 05, 2007 6:40 pm   

[2.14a] Issues with #forall and %regex - Program crashing with access violations
 
I'm getting some weird results on code that worked on Zmud. I created a snippet in CMUD to demonstrate the point:

Code:
#local $temp_name $test1 $test2
$temp_name = %null
$test1 = "400_500_Vial4"
$test2 = "400_500_Vial5|401_501_Vial6"
#say ""
#say Test1: $test1
#forall $test1 {
  #say Loop Variable: %i
  #say %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result: $temp_name
  }
  #forall $test2 {
  #say Loop Variable2: %i
  #noop %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result2: $temp_name
  }


Results:
Test1: 400_500_Vial4
Loop Variable: 400_500_Vial4
1
Regex Result: Vial4
Loop Variable2: 400_500_Vial5
Regex Result2: Vial4
Loop Variable2: 401_501_Vial6
Regex Result2: Vial4

The Error:
It evaluated the %regex after the #noop in Zmud, but no longer. It works with #say %regex, but not with #noop %regex.

I'm also getting crashes when I alter this slightly. Changing first loop to $test2 (just like the second loop):

Code:
#local $temp_name $test1 $test2
$temp_name = %null
$test1 = "400_500_Vial4"
$test2 = "400_500_Vial5|401_501_Vial6"
#say ""
#say Test1: $test1
#forall $test2 {
  #say Loop Variable: %i
  #say %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result: $temp_name
  }
  #forall $test2 {
  #say Loop Variable2: %i
  #noop %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result2: $temp_name
  }


Result is a program crash - Access violation at address 00080040. Read of address 00080040.

Another small change that causes a program fail as well. Change both loops to use $test1:
Code:
#local $temp_name $test1 $test2
$temp_name = %null
$test1 = "400_500_Vial4"
$test2 = "400_500_Vial5|401_501_Vial6"
#say ""
#say Test1: $test1
#forall $test1 {
  #say Loop Variable: %i
  #say %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result: $temp_name
  }
  #forall $test1 {
  #say Loop Variable2: %i
  #noop %regex( %i, "\d+_\d+_(\w+)", $temp_name)
  #say Regex Result2: $temp_name
  }


Result is this also causes an Access violation at address bla bla bla.

So there may be multiple issues going on and I'm not sure why this is causing errors and crashing apart from the obvious functionality difference from Zmud.
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Dec 05, 2007 7:47 pm   
 
You need to use #CALL in CMUD instead of #NOOP. Try that and see if it helps. There were also a couple of bugs in v2.14a with local variables that might also be causing problems.

The issue with using the same local variable in nested loops is already fixed in 2.15.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Wed Dec 05, 2007 8:54 pm   
 
When I replace #NOOP with #CALL it works properly and I cannot get it to crash no matter what else I change around. It seems like it is very specific to #noop.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Wed Dec 05, 2007 9:00 pm   
 
If using #CALL instead of #NOOP for CMUD is the ultimate solution, you may want to consider adding a check for this in the compatibility report since this was valid in ZMud. That or prevent it from compiling successfully when a #NOOP is used with %regex so that it wouldn't cause an AV.

Also, I was reading through your response and I'll clarify that the code isn't a nested loop. It's probably just the spacing just gives it that impression. I just ran an almost identical loop twice with slightly different input.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Dec 06, 2007 2:23 pm   
 
In any case, the crash was already fixed in v2.15. So #NOOP should still work in 2.15 for compatibility, but #CALL is recommended. This was true in zMUD also. #NOOP was replaced with #CALL many years ago.
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