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

Mutants! - Crash when enumerating "stores" #20

Closed enusbaum closed 4 years ago

enusbaum commented 4 years ago

Mutants! crashes when performing a "stores" command after buying land and opening a store.

Unhandled exception. System.Exception: Unsupported Key Length: 30
   at MBBSEmu.Btrieve.BtrieveFileProcessor.GetByKeyNextNumeric(BtrieveQuery query)
   at MBBSEmu.Btrieve.BtrieveFileProcessor.SeekByKey(UInt16 keyNumber, ReadOnlySpan1 key, EnumBtrieveOperationCodes btrieveOperationCode, Boolean newQuery)
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.qnpbtv()
   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, Queue1 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.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Looking at the API for qnpbtv(), it assumes a query performed before it and passes the same query the second time for the "Next" part of the operation.

Will need to double check the logic in that if a new key is passed in as part of the "Next" operation, if it should be considered a new query to get next from the current file position.

enusbaum commented 4 years ago

Verified Btrieve file for Stores (MJWMUTS.DAT) is using String as the datatype for the second index.

Also verified that while the BtrieveFileProcessor.SeekByKey() supported GetKeyNext, it only performed a string next on a key type of ZString.

I'm going to enhance the routine for query type to include string processing for both ZString and String key Types.

enusbaum commented 4 years ago

Fix pushed in bc302be34a1f5478257b80457fbc3687333d4177

Will verify with tester 👍

enusbaum commented 4 years ago

Confirmed fixed! Closing.