mbbsemu / MBBSEmu

The MajorBBS Emulation Project is an Open Source, Cross-Platform emulator for easily running The MajorBBS & Worldgroup Modules
https://www.mbbsemu.com
MIT License
129 stars 14 forks source link

[MHWWHL] Wheel of Fame! - Crashing on start of a game #69

Closed tuday2 closed 3 years ago

tuday2 commented 4 years ago

Module Information

Identifier: MJWWHL Module Name: Wheel of Fame! Version: Unknown

Describe the bug Module crashes once you start a game (basic commands seem to work now!)

To Reproduce Steps to reproduce the behavior: Enter module - Type "Play" -- after about 10 seconds a new game will start and after it announces the Multiplier for the game it crashes

Expected behavior Game plays properly

Screenshots Annotation 2020-08-29 104102

MBBSEmu Error:
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key '65535' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.outprf()
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke(UInt16 ordinal, Boolean offsetsOnly)
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
   at MBBSEmu.CPU.CpuCore.Tick()
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.Module.MbbsModule.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassSetState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.HostProcess.MbbsHost.WorkerThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ThreadHelper.ThreadStart()

Software Information:

OS: Windows 2019 Server Standard Telnet Client: Netrunner

API REPORT {"UniqueIdentifier":"MJWWHL","File":"MJWWHL.DLL","Imports":{"DOSCALLS":[89],"PHAPI":[16],"MAJORBBS":[574,762,827,459,713,460,625,330,437,516,561,599,550,628,313,53,485,534,326,578,604,566,650,441,389,543,455,456,544,65,492,589,331,476,559,474,521,761,335,463,403,629,113,785,787,786,582,117,119,162,579,401,573,654,484,520,665,571,560,77,11,659,486,621,351,522,94,411,205,225,622,757,357,167],"GALGSBL":[40,63,72,59]}}

enusbaum commented 4 years ago

This might be an issue where outprf() is being called on a background/worker function (rtkick(), etc.) and the channel being passed in is -1 (0xFFFF or unsigned 65535).

It should be easy to duplicate and check the stack to see which worker method is invoking this. We might want to also add code to outprf() to do nothing if the channel is < 0

enusbaum commented 3 years ago

Double checked and confirmed that USRNUM is set to -1 when in RTKICK routines for my own sanity.

image

I added a check in OUTPRF to verify the channel exists prior to trying to send to the channel. This made Wheel of Fame playable.

image

Seeing if I can use the TestSession object to write a Unit Test for OUTPRF then I'll submit a PR for this item.