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
132 stars 14 forks source link

[ELWIC] Infinity Complex - Module crashes on shutdown #75

Closed tuday2 closed 4 years ago

tuday2 commented 4 years ago

Module Information

Describe the bug Module crashes on shutdown

To Reproduce Steps to reproduce the behavior:

  1. Add module to moduleConfig.json
  2. Start MBBSEmu
  3. CTRL-C and shutdown MBBSEmu
  4. Module crashes on shutdown routine

Expected behavior Module shuts down normally

Screenshots

2020-09-01 20:12:48.6764 Info MBBSEmu.HostProcess.MbbsHost.<Shutdown>b__18_0 Calling shutdown routine on module ELWIC
2020-09-01 20:12:48.6888 Warn MBBSEmu.Btrieve.BtrieveFileProcessor.SeekByKey Adjusting Query Key Size, Data Size 7 differs from Defined Key Size 25
2020-09-01 20:12:48.6888 Warn MBBSEmu.Btrieve.BtrieveFileProcessor.SeekByKey Adjusting Query Key Size, Data Size 8 differs from Defined Key Size 25
Unhandled exception. System.Exception: Unknown GetOperandOffset MemoryBase
   at MBBSEmu.CPU.CpuCore.GetOperandOffset(OpKind opKind)
   at MBBSEmu.CPU.CpuCore.GetOperandValueUInt16(OpKind opKind, EnumOperandType operandType)
   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.CallModuleRoutine(String routine, Action`1 preRunCallback, UInt16 channel)
   at MBBSEmu.HostProcess.MbbsHost.Shutdown()
   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:

API Report {"UniqueIdentifier":"ELWIC","File":"ELWIC.DLL","Imports":{"DOSCALLS":[89],"PHAPI":[16],"MAJORBBS":[441,574,326,544,65,437,455,571,566,543,158,492,589,331,550,559,601,357,534,757,444,520,456,474,629,463,628,476,403,650,317,485,624,573,335,522,401,229,475,462,225,637,205,565,510,467,420,350,511,486,351,117,162,167,713,230,560,516,433,654,665,113,477,578,584,505,621,313,53,226,94,11,408,77,402,334,718,579,604,582,580,366,377,659,581,603],"GALGSBL":[40,37,59,21,7,72,36]}}

enusbaum commented 4 years ago

I was able to get the module to init locally.

Delete any .EMU files that might be there from previous versions of MBBSEmu and give it another go.

Just to verify, my local demo version is iNfInItY CoMpLeX v6.04

tuday2 commented 4 years ago

You are correct, it just crashes on shutdown. -- changed issue

enusbaum commented 4 years ago

Issue caused by the operation:

{cmp word ptr es:[bx+di],0}

I've added handling for when the Memory Base is BX and the Memory Index is DI to the method GetOperandOffset

Also added the instruction to the error message to help with debugging in the future.

This method can probably be refactored to call Registers.GetValue() on the MemoryIndex value, but I'd want to be able to benchmark the performance impact of making a call from within this method. For now, the switch statement is fine.

enusbaum commented 4 years ago

Fixed in https://github.com/enusbaum/MBBSEmu/pull/85