|
Delphi03 Novice
Joined: 20 Aug 2004 Posts: 37 Location: Illinois
|
Posted: Fri Jul 02, 2010 11:44 pm
[3.19-3.26] Trigger Infinite Loop |
I recently upgraded from 3.17 beta to 3.19 beta. Since then, if I try to log in to one of my games, two of my long-time working triggers seems to be causing issues:
Code: |
<trigger name="FixSlashes" type="Command Input" priority="100" regex="true" enabled="false" id="10">
<pattern>(.*)</pattern>
<value>#substitute %replace(%replace(%1, %char(92), "&bs."), %char(47), "&fs.")</value>
</trigger> |
And this one as well:
Code: |
<trigger name="ReplaceColors" priority="20" regex="true" id="2">
<pattern>(.*)</pattern>
<value><![CDATA[#substitute %replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%replace(%subregex(%subregex(%replace(%replace(%subregex(%subregex(%replace(%replace(%replace(%replace(%replace(%replace(%1, ^B, %ansi(high, blue)), ^b, %ansi(blue)), ^C, %ansi(high, cyan)), ^c, %ansi(cyan)), ^E, "<b>"), ^e, "</b>"), "\^F", "@randHigh()"), "\^f", "@randHigh()"), ^G, %ansi(high, green)), ^g, %ansi(green)), "\^H", "@randLow()"), "\^h", "@randLow()"), ^I, "<i>"), ^i, "</i>"), ^K, %ansi(blink, high, red)), ^k, %ansi(blink, red)), ^N, %ansi(reset)"</b></i></font>"), ^n, %ansi(reset)"</b></i></font>"), ^O, "<font color="#FF9900">"), ^o, "<font color="#CC9900">"), ^P, "<font color="#FFB6C1">"), ^p, "<font color="#FF1493">"), ^R, %ansi(high, red)), ^r, %ansi(red)), ^T, "<font color="#996600">"), ^t, "<font color="#A0522D">"), ^V, %ansi(high, magenta)), ^v, %ansi(magenta)), ^W, %ansi(high, white)), ^w, %ansi(grey)), ^Y, %ansi(high, yellow)), ^y, %ansi(yellow)), %char(38)bs., "\"), %char(38)fs., "/")]]></value>
</trigger> |
My assumption being that either the match against (.*) or the multi-nested %replace() (or the combination of the two) are causing the problem.
These worked fine since early 3.x beta (when I moved over to cmudpro) as well as on zmud 7.21.
Any assistance would be appreciated (up to and including any nicer ways to write the above in a nicer, friendlier manner!) |
|
Last edited by Delphi03 on Sun Sep 12, 2010 4:38 am; edited 1 time in total |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Jul 03, 2010 2:49 am |
Those look like custom color codes. If that's what they are, did you know there's a whole section in Preferences dedicated to Colors? One of the tabs therein are for custom color codes.
1)open up Preferences and navigate to the Ansi Color section
2)click on the Color Syntax tab
3)fill in the Foreground Color Codes boxes (just the letters, not the ^)
4)where it says Syntax for Foreground Color, type in ^F (the F is a placeholder for the actual letter code) |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Delphi03 Novice
Joined: 20 Aug 2004 Posts: 37 Location: Illinois
|
Posted: Sat Jul 03, 2010 3:16 am |
I believe I tried using the before, but I imagine I simply mixed up the syntax.
Assuming that works, I'll be able to remove all of the standard ansi colors from that trigger, but I'd still need it to support the "additional" colors and formatting options.
Unfortunately, the game is currently down for a backup, update, and reboot so I won't be able to test whether or not I can get the supplied color syntax working; even still, the issue exists with both triggers resulting in an infinite loop if enabled (both independently will cause this) requiring a restart from the task manager.
Thanks for the tip though, I'll give that a try again and see if I can reduce this trigger down a bit!
Update: I tried using the color option but was unable to get it successfully working:
Code: |
^GThis is some green text.^N |
I set the text box next to the Foreground Bright Green patch to "G".
I set the Syntax for Foreground Color to "^F".
I set the Syntax for Resetting Colors to "^N".
I check the Syntax Enabled box, click apply, and then enter a few commands that should return output that now has color.
Unfortunately, this does not appear to be the case and the server returns exactly as it would if I had done nothing with the Color Syntax tab at all. |
|
|
|
Delphi03 Novice
Joined: 20 Aug 2004 Posts: 37 Location: Illinois
|
Posted: Sat Sep 11, 2010 3:17 am |
This issue still exists in 3.25.
Does anyone else have any other suggestions? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Sep 11, 2010 5:10 pm |
Oh, crap, I totally spaced on this. Color Syntax doesn't cause CMud to translate color syntax code into ansi color, it causes Cmud to translate ansi color into color syntax code.
Anywho, you might try combining your triggers, and in addition perhaps avail yourself of a #FORALL loop and local variable. %replace() I believe is still considered a very slow function, so something like this might work a lot better for you:
Code: |
$line = %1
$replacechars = {"/"|"\"|each color syntax code}
#forall $replacechars {
#switch (%i = "/") {$line = %replace($line,"/","whatever you wanted to replace it with")}
(%i = "\") {$line = %replace(...}
}
#sub $line
|
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Delphi03 Novice
Joined: 20 Aug 2004 Posts: 37 Location: Illinois
|
Posted: Sat Sep 11, 2010 9:15 pm |
Thanks for this; however, this suffers the same issue.
Code: |
$line = %1
$replace_string = {"^B"|"^b"}
#forall $replace_string
{
#switch (%i = "^B") {$line = %replace($line, %i, %ansi(high, blue))}
(%i = "^b") {$line = %replace($line, %i, %ansi(blue))}
}
#substitute $line |
If I enabled this to a trigger on (.*), then enter #echo ^BTest -- CMUD will lock up.
Update: After reverting back to 3.16b, the above snippet says "Infinite Loop detected in (.*)"
It still locks up even if I click "Disable"; in 3.19 to 3.26, this prompt never shows and it directly crashes.
The original version of the trigger (first post) doesn't cause issues in 3.16b, other than being sluggish to process all the incoming text. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sun Sep 12, 2010 4:19 pm |
Try turning off the "Trigger on Trigger" option for the trigger and see if that helps. The problem is that after you execute #SUB, CMUD is checking to see if the new text matches any triggers.
Since your trigger has a pattern of .*, it matches everything, causing the infinite loop. Turning off "Trigger on Trigger" will prevent CMUD from running additional triggers on the #SUB result. |
|
|
|
Delphi03 Novice
Joined: 20 Aug 2004 Posts: 37 Location: Illinois
|
Posted: Sun Sep 12, 2010 5:01 pm |
I disabled the "Trigger on Trigger" option.
I also disabled all other triggers.
The issue still occurs; both with the local-variable-ized version and the straight, nested-%replace() version, causing cmud to enter an infinite loop/lock up and need to be closed via the task manager.
Update: Maybe this is a strange question to ask, but is/are the trigger(s) shown now causing cmud/cmudpro to crash for either of you, or is it just me?
I could understand if this was just happening to me (maybe some strange, random environment setup issue?), but it seems more like something was changed between 3.16b and 3.19 (and hasn't changed since) that breaks #sub %replace() on (.*) as something as simple as:
Code: |
#substitute %replace(%1, "^B", %ansi(high, blue)) |
causes 3.26 to lock up while trying to parse
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Sep 13, 2010 6:02 pm |
I was able to reproduce the infinite loop, so it's definitely a bug in CMUD. Added this to the bug list for the next update.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Sep 16, 2010 7:26 pm |
I learned more about this issue today. The problem is with the (.*) trigger pattern. The #SUB command (and #CW) have the Repeat within Line option enabled internally.
This allows the #SUB and #CW to fire more than once on the same line.
When CMUD gets to the end of the line, the (.*) pattern still matches NULL text. It's because * matches ZERO OR MORE characters. So CMUD gets into an infinite loop matching the end of the line.
Changing the pattern to (.+) fixes the issue. But I'll still try to fix this so that CMUD doesn't go into an infinite loop. |
|
|
|
|
|
|
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
|
|