[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  msgbox in onpluginbroadcast (from gmcp handler) breaks mccp decompression

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: msgbox in onpluginbroadcast (from gmcp handler) breaks mccp decompression
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Sun 15 Jan 2012 11:27 PM (UTC)  quote  ]
Message
Fiendish said:

I thought having the messagebox up halted script processing. I wouldn't have expected a new broadcast to happen.


If you leave install my modified version (so it doesn't actually crash) you will notice that, with the message box up, messages (from the MUD) scroll underneath.

That script halted, yes. But I think the underlying design of MFC lets a "modal" dialog box actually process more messages. In fact, they implement modal boxes by simply disabling the underlying window. You notice this because things scroll by while you have the world configuration dialog box open, for example.

Effectively I think the underlying MFC design is pulling out a new incoming comms message, sending to the document class, and it then processes it in the normal way. It doesn't know the script engine is "paused" processing an earlier packet.

Probably what is crashing is the Lua script engine being re-entered.

Quote:
So utils dialogs are never safe?


Like I said, without the re-entry, I could have one dialog up for a while. But putting up dialogs in the low-level packet processing (where the GMCP packets come in) is probably asking for trouble.

My tentative suggestion would be to queue up such dialogs so they get pulled out in "main" processing, not half-way through handling a packet.

The whole thing wasn't really designed with re-entrancy in mind. And a while back a couple of things were added that tended to exacerbate this problem:


  • Having blocking dialogs, like utils.msgbox

  • Putting hooks into low-level code (like telnet subnegotiation) which allows you to call scripts, which lets you put up such dialogs.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (849 posts)  [Biography] bio   Global Moderator
Date Sun 15 Jan 2012 10:31 PM (UTC)  quote  ]

Amended on Sun 15 Jan 2012 10:39 PM (UTC) by Fiendish

Message
Quote:
a new packet arrives, and if that also causes a plugin broadcast


I thought having the messagebox up halted script processing. I wouldn't have expected a new broadcast to happen.

Quote:
while the message box is open, Windows' message queue starts filling up
So utils dialogs are never safe?

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Sun 15 Jan 2012 09:46 PM (UTC)  quote  ]
Message
Your test is setting up a race condition, with re-entrant behaviour that is not really designed to be handled.

This modified version, I had sitting there for a while (with the message box up) without a crash:


function OnPluginBroadcast (msg, id, name, text)
   if id == "3e7dedbe37e44942dd46d264" then -- the Aardwolf GMCP handler
     if not foo then
      foo = true
      utils.msgbox("Test!")
      foo = false
     end -- if
   end -- level info
end


Your test, if you leave the message box up, interrupts the processing of the incoming packet by displaying the message box. So that packet is partly processed. Then while the message box is up, a new packet arrives, and if that also causes a plugin broadcast, we have now re-entered utils.msgbox. When these eventually get dismissed (or maybe without dismissing them) as the stack unwinds, things get out of kilter.

Another possible explanation is that, while the message box is open, Windows' message queue starts filling up (eg. with incoming comms messages) and some of them get discarded, leading to decompression errors.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (849 posts)  [Biography] bio   Global Moderator
Date Sun 15 Jan 2012 02:28 AM (UTC)  quote  ]

Amended on Sun 15 Jan 2012 02:29 AM (UTC) by Fiendish

Message
Adding the following simple plugin to the Aardwolf client package causes decompression errors. Sometimes MUSHclient crashes too. (Just load the plugin, connect, and wait 20 seconds or so.)


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Error_Test"
   author="Fiendish"
   id="aaaaaa47725d717d6292a680"
   language="Lua"
   purpose="Compression Errors"
   date_written="2013-07-05 16:46:02"
   requires="4.81"
   version="1.0"
   save_state="y"
   >
</plugin>

<script>
<![CDATA[
function OnPluginBroadcast (msg, id, name, text)
   if id == "3e7dedbe37e44942dd46d264" then -- the Aardwolf GMCP handler
      utils.msgbox("Test!")
   end -- level info
end

]]>
</script>
</muclient>

http://aardwolfclientpackage.googlecode.com/
[Go to top] 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.


894 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]