Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Bug reports ➜ utils.inputbox in a trigger duplicates received text

utils.inputbox in a trigger duplicates received text

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Sun 03 Jan 2021 02:54 AM (UTC)

Amended on Sun 03 Jan 2021 03:01 AM (UTC) by Fiendish

Message
If a trigger spawns an inputbox, the output gets wonky if new messages (including GMCP) arrive while the inputbox is open.


Here's a minimal test case:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="TEST"
   author="Fiendish"
   id="52766ef28a7a682387d59687"
   language="Lua"
   purpose="Test"
   date_written="2020-12-30 00:00:00"
   version="1.00"
   >

</plugin>
<aliases>
<alias
   script="test"
   match="test"
   enabled="y"
   sequence="100"
   ignore_case="y"
>
</alias>
</aliases>

<triggers>
<trigger
   enabled="n"
   match="*"
   sequence="100"
   send_to="12"
   name="test"
>
<send>
EnableTrigger("test", false)
local input = utils.inputbox("Hi", "Hello", "Value")
</send>
</trigger>
</triggers>

<script>
<![CDATA[
   function test()
      EnableTrigger("test", true)
      Send("echo FIRST MESSAGE")
      Send("echo SECOND MESSAGE")
   end
]]>
</script>
</muclient>


I connect to Aardwolf with an empty world that has only this plugin loaded in it and then type "test" to activate the alias. I see:

Quote:

echo FIRST MESSAGE
echo SECOND MESSAGE
FIRST MESSAGEFIRST MESSAGE

SECOND MESSAGE



If I remove EnableTrigger("test", false) from the trigger script, the situation gets much worse with spawning many input boxes, and then this might happen while I'm frantically trying to close them:

Quote:

echo FIRST MESSAGE
echo SECOND MESSAGE
FIRST MESSAGEFIRST MESSAGE
FIRST MESSAGE
FIRST MESSAGE
FIRST MESSAGE

SECOND MESSAGE

{-=Masaki=-} Hassaikai Yakuza: dont really care mate

WARFARE: Genocide has been declared by Ivar for levels 1 to 18!
WARFARE: The preparation grounds shall close in approx 2 minutes!
WARFARE: Type 'combat' to join the war. No death penalties!

SECOND MESSAGE

{-=Masaki=-} Hassaikai Yakuza: dont really care mate

SECOND MESSAGE

{-=Masaki=-} Hassaikai Yakuza: dont really care mate

SECOND MESSAGE

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 03 Jan 2021 03:52 AM (UTC)
Message

I can reproduce it, but I’m not sure why.

If I remove EnableTrigger(“test”, false) from the trigger script, the situation gets much worse with spawning many input boxes,

Well you expect that, right? It is matching “*" multiple times and thus putting up multiple input boxes. Not a recommended thing to do.

As for the first problem, it seems to be something to do with MCCP, because if you turn that off the problem goes away.

I suspect what is happening is that the first echo “FIRST MESSAGE” causes the trigger to fire, and because the inputbox does not return (until you dismiss the dialog box) then the input from the MUD is not properly cleaned up. Or to put it another way, it probably isn’t re-entrant.

If you turn on packet debug it seems to think that a second FIRST MESSAGE has been sent from the server, which clearly did not in fact happen, so there is bogus input in the input buffer, probably caused by the lack of cleanup as mentioned earlier.

As a workaround I suggest not putting up input boxes when triggers fire, there is too much possibility of this sort of problem.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #2 on Sun 03 Jan 2021 05:58 AM (UTC)
Message
Quote:
Well you expect that, right?

I'm not sure. I kind of expected that the plugin won't keep processing new lines until the input box is done, but obviously that isn't infinitely sustainable.

But the more related issue is that the repeated output also duplicates more and more with the repeated input boxes.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 03 Jan 2021 07:12 AM (UTC)
Message
You might reasonably expect that a modal dialog box like utils.inputbox would stop processing until you dismissed it, however MFC implements modal dialogs in a somewhat strange way. That is, the main event loop is still active. Thus you have the possibility that non-re-entrant code will fail under certain circumstances.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,863 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.