nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
129 stars 92 forks source link

DotNET: Add crash handler override support. #1708

Closed jhett12321 closed 10 months ago

jhett12321 commented 10 months ago

Adds support for overriding the NWNX crash handler.

This allows a custom C# handler to attempt to resolve a managed backtrace before crashing the server, giving better visibility when debugging. And hopefully less Anvil bugs ending up in the NWNX chat ;)

Example from a double-free issue:

image

I tried to implement this through the existing MessageBus::Broadcast("NWNX_CORE_SIGNAL") system, but wasn't able to reach managed code again before encountering more dragons.

mtijanic commented 10 months ago

This is fine. By the way, you should be able to call the original crash handler from either managed code or the dotnet plugin. In the cpp, just declare as extern "C" void nwnx_signal_handler(int sig); and then call. In the plugin, use P/Invoke or whatever.