Tuesday 7 April 2009

Python standard library: pickletools

There's a crash bug in the in progress Stackless Python 3.1a2 release, but only on Linux. The particular use case, is where a tasklet is run for a very short time before being interrupted, pickled at its current point of execution, unpickled to a new version of the tasklet and then run. However, there appears to be some corruption in the pickling, which results in a recreated tasklet that appears to loop forever.

Now, the first step is to understand what pickle output. In the past, I've broken down the pickle strings into a readable form by hand. This time, I googled for "disassembling python pickle dump" and one of the first hits was pickletools. Now, this code appears to be somewhere within a Sourceforge repository, and I am too lazy to track it down, so I googled for "pickletools" and found it was now in the standard library for Python 2.6. Bingo!

Trying it out gives a dump which looks like this:

>>> pickletools.dis(s)
0: \x80 PROTO 3
2: c GLOBAL 'stackless tasklet'
21: q BINPUT 0
23: ) EMPTY_TUPLE
24: R REDUCE
25: q BINPUT 1
27: ( MARK
28: K BININT1 8
30: N NONE
31: K BININT1 0
33: ] EMPTY_LIST
34: q BINPUT 2
36: c GLOBAL 'stackless._wrap frame'
59: q BINPUT 3
61: c GLOBAL 'stackless._wrap code'
83: q BINPUT 4
85: ( MARK
...
Disassembling both the Linux and Windows pickle dumps of the tasklet, gives me the point at which they differ.

Windows:
  ...
400: N NONE
401: N NONE
402: J BININT -1
407: K BININT1 4
409: ) EMPTY_TUPLE
...
Linux:
  ...
400: N NONE
401: N NONE
402: K BININT1 31
404: K BININT1 4
406: K BININT1 120
...
Brilliant :-) This is a huge help and will save me a lot of time.

Monday 6 April 2009

topmudsites.com: Mud Server Status Protocol

Link: MSSP (Mud Server Status Protocol)

A new development to make MUDs more visible. MUDs which support it can be registered to be scanned automatically, allowing them to have update to date entries in MUD lists.

MSSP Mud Crawler - The only site scanning MSSP supporting MUDs as yet.

The original design is to embed it in the telnet option negotiation, and there's some talk about adding support for it to the maintained version of MudOS, FluffOS.

The telnet option negotiation follows the standard approach:

IAC WILL MSSP    indicates the server supports MSSP.
IAC DO MSSP indicates the client supports MSSP.
IAC DONT MSSP indicates the client doesn't support MSSP.
It is expected that the work involved in getting existing MUDs to implement a telnet option negotiation solution may be prohibitive, and to that end, a easier to add, normal text-based login screen mode is also being fleshed out.
A crawler sends the following text when it connects:
MSSP-REQUEST\r\n
The MUD server then responds with:
MSSP-REPLY-START\r\n
Followed by a sequence of lines in the pattern:
KEY\tVALUE\r\n
Etc..
The MudBytes forum has a dedicated forum for MSSP.