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

[ELWWOW] War of Worlds! - Module crashes on initialization #139

Closed tuday2 closed 3 years ago

tuday2 commented 3 years ago

Module Information

Describe the bug Module crashes on initialization

To Reproduce Steps to reproduce the behavior:

  1. Add module to moduleConfig.json
  2. Load MBBSEmu
  3. See error

Expected behavior Module loads

Screenshots

Info MBBSEmu.HostProcess.ExportedModules.Majorbbs.mkdir Created Directory: D:\MbbsX64\modules\elwwowd\ELWWOWEM
Critical Exception has occurred:
System.OutOfMemoryException: Volatile Memory declaration > 16k
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.dclvda()
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke(UInt16 ordinal, Boolean offsetsOnly)
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
   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.AddModule(MbbsModule module)
   at MBBSEmu.Program.Run(String[] args)

Software Information:

enusbaum commented 3 years ago

We define the max volatile data size as 16K

https://github.com/enusbaum/MBBSEmu/blob/master/MBBSEmu/HostProcess/ExportedModules/Majorbbs.cs#L2780

It looks like War of Worlds! is trying to allocate more than that. We can up this number to 32k, 64k, etc. One thing to keep in mind is that one area of volatile data is declared per channel, so on 256+ line mbbsemu setups, this could consume a bunch of memory if we over allocate.

enusbaum commented 3 years ago

This module is not the VDA pig I thought it was 🐷

image

Based on this, it takes the output buffer size (OUTBSZ) which is 8k by default on WG2, then adds 0xFE80, overflowing to 7809 bytes, then adds 294 which gives us a total of 8469 bytes... on a default set.

The issue with MBBEmu? We declare ushort.MaxValue as our OUTBSZ. If we modify that to be the same as WG2 (and also modify GSBL.BTUOBA in kind), we should be good to go on this one.

enusbaum commented 3 years ago

This was fixed in #147

To get War Of Worlds starting, you'll need to manually create the Btrieve Files for the different games. If you're only running one game, you'll need to rename the .VIR files to 0.DAT, with 0 being the Btrieve file for Game 1.

Once doing this, you'll get an error trying to get a record from a Btrieve file where the record doesn't exist. MBBSEmu will throw an exception. We'll log this as another defect as it's unrelated to this one and it's Btrieve specific.