MBBSEmu icon indicating copy to clipboard operation
MBBSEmu copied to clipboard

[MBBSEmu] wishlist: handle crashes and SYS SHUTDOWN

Open ftoledo opened this issue 4 years ago • 1 comments
trafficstars

MBBSEmu should capture module crashes and avoid closing the application completely.

It should have some error counters, leave them in a log but it should keep the application active until it is closed (for example by a /SYS SHUTDOWN command)

ftoledo avatar Oct 25 '21 02:10 ftoledo

This is an interesting idea! We'd probably need to do it in a couple steps:

If we wrap the calls to the internal function delegates for the mapped APIs within the CALL opcode with an exception handler (or handle it inside the API and evaluate a return code), we can set the CPU Register HALT to true and add another Register Boolean value for Exception (or similar)

Example Point to add this logic: https://github.com/mbbsemu/MBBSEmu/blob/master/MBBSEmu/CPU/CPUCore.cs#L2859

Halting the CPU will stop execution and hand control back over to the MBBS Host. The MBBS Host could then evaluate this flag and take action accordingly if the module is in an exception state (Disable the Module, attempt to call shutdown on the Module, etc.)

Example Point to add this logic: https://github.com/mbbsemu/MBBSEmu/blob/63de1eccc3c9cdff195f6255791910f94169c416/MBBSEmu/HostProcess/MbbsHost.cs#L1050

We'd need to perhaps have a fallback where try shutdown, if there's an exception in shutdown, just disable the module. Just so we don't have a cascade of errors.

enusbaum avatar Oct 25 '21 11:10 enusbaum

Crash Isolation was implemented in #590

Now when a module crashes, users are gracefully exited from the module and a crash report is generated.

enusbaum avatar Dec 22 '23 01:12 enusbaum