crash on connect+editbox

Posted by Fiendish on Mon 02 May 2011 04:33 PM — 5 posts, 15,538 views.

USA Global Moderator #0
The following code in a plugin will cause MUSHclient 4.72 to crash (using Windows 7) when included in a world file that gets loaded automatically at program start (but not when loaded while the world is already up and running):

function OnPluginInstall()
    Connect()
    utils.editbox("hello","hello","hello")
end


Or if you have two different plugins, and the first one to load calls

function OnPluginInstall()
    Connect()
end

and the second one to load calls

function OnPluginInstall()
    utils.editbox("hello","hello","hello")
end

That will crash too. But the reverse load order will not.
Amended on Mon 02 May 2011 04:44 PM by Fiendish
USA Global Moderator #1
If I change the editbox call to be inside of a

DoAfterSpecial(1, ...


Then I tend to (but not always) get "Could not decompress text from MUD: unknown compression method" errors on startup after dismissing the dialog.


DoAfterSpecial(10, ...

seems to work fine, but the delay is rather long and likely system dependent.
Amended on Mon 02 May 2011 05:45 PM by Fiendish
Australia Forum Administrator #2
Sounds like a race condition. I'll look into it.
Australia Forum Administrator #3
Yes, it's a race condition. Plugins are loaded quite early as part of world startup. Some internal structures have not been allocated at that point because, for one thing, we need to know how many lines the user wants in the output buffer in order to allocate a lookup table to quickly index into the buffer.

Calling connect starts a sequence, which, when the connection is established the world tries to send your login name, which then hits this unallocated buffer. The dialog box effectively pauses the loading sequence, making the problem much more prominent.

I have added an extra test for the existence of that buffer before attempting to display things. That at least stops the crash but is not ideal. Some lines are just thrown away.
Australia Forum Administrator #4
I think it is fixed reasonably well now. I would be cautious about doing stuff like that in OnPluginInstall, but it seems to handle it better now.


https://github.com/nickgammon/mushclient/commit/9ac3d519d5