Skip to content

NullReferenceException thrown in ComposeSlotOverlays patch #35

@BinToss

Description

@BinToss

As identified by Zaldaryon of OptiTime and reported by Introdile.
Since it was reported, OptiTime was updated to mitigate crashes caused by the NREs.

💬 Introdile, Dec 4th 2025, 03:06:14

Thank you for making this! It's been a nice mod to have. I have been getting a crash today though, that points to this mod. It seems to happen at random when I click on an item inside a chest. I'm not sure of any specifics to trigger it, because the game works fine for a while after loading, and I can mess with chests just fine just fine, but then I suddenly crash upon interacting with an item inside a chest or storage vessel. It points to Toolsmith as well, but the item I was interacting with during these crashes weren't items from Toolsmith. One was a flower, another a beehive from From Golden Combs, and the most recent one was a plaster block, I think.

Crash Report
Running on 64 bit Windows 10.0.19045.0 with 16335 MB RAM
Game Version: v1.21.5 (Stable)
12/3/2025 6:50:23 PM: Critical error occurred
Loaded Mods: ageofflax@1.1.1, buzzwords@1.8.0, cavepainting@0.1.2, floralzonescosmopolitanregion@1.0.11, floralzonesmediterraneanregion@1.0.19, fadynasties@1.2.5, fagothic@1.3.1, fagreenwich@1.4.2, fahussar@1.1.3, falandsknecht@1.2.2, fatemplar@1.4.3, faviking@1.0.0, pantherinae@1.2.5, geoaddons@1.4.4, immersivelanterns@0.3.1, just3roots@0.6.0, lightlevelone@2.0.0, longtermfood@0.5.5, manualdough@1.1.7, millwright@1.3.1, nobearjetpacks@1.0.2, overhaullib@1.15.5, playermodellib@1.7.0, primitivesurvival@4.0.2, prospecttogether@2.1.2, rubblewithyourhammer@1.0.0, scrollrackable@1.4.0, shelfobsessed@1.9.1, soaplyeandbloom@1.3.6, tankardsandgoblets@1.3.4, temporalsymphony@2.2.2, valkyrjahair@2.3.0, game@1.21.5, vsimgui@1.1.16, wildfarmingrevival@1.4.2, aculinaryartillery@2.0.0-dev.10, age-of-flax-balance-patch@1.0.1, alchemy@1.7.21, animalcages@4.0.2, anthrowolfrace@0.1.2, attributerenderinglibrary@2.4.0, egocaribautomapmarkers@4.0.3, betterfirepit@1.2.0, betterruins@0.5.4, bloodtrail@1.1.8, butchering@1.10.11, carryon@1.12.1, cartwrightscaravan@1.8.0, clothierheirloomsmod@1.0.2, combatoverhaul@0.10.19, commonlib@2.8.0, configlib@1.10.11, danatweaks@3.6.0, dressedtokillredux@1.0.0, expandedstomach@1.2.7, extendedcreation@1.1.7, farseer@1.3.2, floralzonesxskillsforestrycompat@1.0.0, foodshelves@2.3.3, footprints@1.1.1, fromgoldencombs@1.9.4, genelib@2.1.6, geologymap@1.0.1, handbookdeclutterer@0.6.0, handydaub@1.0.2, hpspinningwheel@1.0.7, hydrateordiedrate@2.3.2, jaunt@2.1.1, koboldrdx@1.2.7, maltiezcrossbows@1.6.8, maltiezfirearms@1.5.3, materialneeds@1.1.6, naturescall@1.3.5, novelty@1.0.18, optitime@1.3.7, packrat@0.8.5, projectiletracker@1.0.6, purposefulstorage@1.5.1, realsmoke@1.1.10, realtimefirepit@1.0.0, regalia@1.2.0, simplebedspawn@1.0.0, smithingplus@1.8.3, statushudcont@4.0.2, stepupadvanced@1.2.3, stonebakeoven@1.2.0, terraprety@7.0.9, toolsmith@1.2.14, creative@1.21.5, survival@1.21.5, windchimes@1.4.1, xlib@0.9.0-pre.2, armory@1.6.2, detailedanimals@0.7.0, elkjaunt@1.3.0, equus@1.2.0, expandedfoods@2.0.0-dev.5, em@3.4.0, mannyextrafirearms@0.5.8, floralzonesextended@1.0.0, playercorpse@1.12.0, quiversandsheaths@0.6.3, revolverarquebus@0.1.1, shearlib@1.2.0, snowshoes@2.1.3, splittablestonepaths@1.0.1, stonequarry@3.5.1, xskills@0.9.0-pre.2, zombpspatch@1.1.0, aldiclasses@1.7.5, sandwich@1.2.9, tailorsdelight@2.1.2, wool@1.8.1, xskillsgilded@1.3.5
Involved Harmony IDs: toolsmith, com.zaldaryon.optitime
System.NullReferenceException: Object reference not set to an instance of an object.
 at Vintagestory.API.Client.GuiElementItemSlotGridBase.ComposeSlotOverlays_Patch0(GuiElementItemSlotGridBase this, ItemSlot slot, Int32 slotId, Int32 slotIndex)
 at Vintagestory.API.Client.GuiElementItemSlotGridBase.ComposeInteractiveElements() in VintagestoryApi\Client\UI\Elements\Impl\Interactive\Inventory\GuiElementItemSlotGridBase.cs:line 249
 at Vintagestory.API.Client.GuiElementItemSlotGridBase.PostRenderInteractiveElements(Single deltaTime) in VintagestoryApi\Client\UI\Elements\Impl\Interactive\Inventory\GuiElementItemSlotGridBase.cs:line 397
 at Vintagestory.API.Client.GuiComposer.PostRender(Single deltaTime) in VintagestoryApi\Client\UI\GuiComposer.cs:line 679
 at Vintagestory.API.Client.GuiDialog.OnFinalizeFrame(Single dt) in VintagestoryApi\Client\UI\Dialog\GuiDialog.cs:line 410
 at Vintagestory.Client.NoObf.GuiManager.OnFinalizeFrame_Patch1(GuiManager this, Single dt)
 at Vintagestory.Client.NoObf.ClientMain.RenderToDefaultFramebuffer(Single dt) in VintagestoryLib\Client\ClientMain.cs:line 1031
 at Vintagestory.Client.GuiScreenRunningGame.RenderToDefaultFramebuffer(Single dt) in VintagestoryLib\Client\MainMenu\Screens\GuiScreenRunningGame.cs:line 250
 at Vintagestory.Client.ScreenManager.Render(Single dt) in VintagestoryLib\Client\ScreenManager.cs:line 760
 at Vintagestory.Client.ScreenManager.OnNewFrame(Single dt) in VintagestoryLib\Client\ScreenManager.cs:line 663
 at Vintagestory.Client.NoObf.ClientPlatformWindows.window_RenderFrame(FrameEventArgs e) in VintagestoryLib\Client\ClientPlatform\GameWindow.cs:line 112
 at OpenTK.Windowing.Desktop.GameWindow.Run()
 at Vintagestory.Client.ClientProgram.Start(ClientProgramArgs args, String[] rawArgs) in VintagestoryLib\Client\ClientProgram.cs:line 338
 at Vintagestory.Client.ClientProgram.<>c__DisplayClass10_0.<.ctor>b__1() in VintagestoryLib\Client\ClientProgram.cs:line 133
 at Vintagestory.ClientNative.CrashReporter.Start(ThreadStart start) in VintagestoryLib\Client\ClientPlatform\ClientNative\CrashReporter.cs:line 95

 Event Log entries for Vintagestory.exe, the latest 3
 ==================================
 { TimeGenerated = 11/25/2025 9:52:38 AM, Site = , Source = Application Error, Message = Faulting application name: Vintagestory.exe, version: 1.21.5.0, time stamp: 0x67fe0000
 Faulting module name: KERNELBASE.dll, version: 10.0.19041.6280, time stamp: 0x56511854
 Exception code: 0xe0434352
 Fault offset: 0x0000000000025369
 Faulting process id: 0x1a30
 Faulting application start time: 0x01dc5e333048c002
 Faulting application path: C:\Users\soldi\AppData\Roaming\Vintagestory\Vintagestory.exe
 Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
 Report Id: 8c77faa7-e504-4349-baf9-89817ad00cb5
 Faulting package full name:
 Faulting package-relative application ID: }
 --------------
 { TimeGenerated = 11/12/2025 4:35:45 PM, Site = , Source = Application Error, Message = Faulting application name: Vintagestory.exe, version: 1.21.5.0, time stamp: 0x67fe0000
 Faulting module name: openal32.dll, version: 1.23.0.0, time stamp: 0x63dd31ad
 Exception code: 0x40000015
 Fault offset: 0x00000000000df046
 Faulting process id: 0x4ba0
 Faulting application start time: 0x01dc5434df3a2999
 Faulting application path: C:\Users\soldi\AppData\Roaming\Vintagestory\Vintagestory.exe
 Faulting module path: C:\Users\soldi\AppData\Roaming\Vintagestory\Lib\openal32.dll
 Report Id: f983c06d-71c9-4211-86d2-9818c80d4b83
 Faulting package full name:
 Faulting package-relative application ID: }
 --------------
 { TimeGenerated = 11/12/2025 4:35:31 PM, Site = , Source = Application Error, Message = Faulting application name: Vintagestory.exe, version: 1.21.5.0, time stamp: 0x67fe0000
 Faulting module name: KERNELBASE.dll, version: 10.0.19041.6280, time stamp: 0x56511854
 Exception code: 0xe0434352
 Fault offset: 0x0000000000025369
 Faulting process id: 0x4ba0
 Faulting application start time: 0x01dc5434df3a2999
 Faulting application path: C:\Users\soldi\AppData\Roaming\Vintagestory\Vintagestory.exe
 Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
 Report Id: 3b6628e8-12b8-471e-b4a8-297b8ac58d2f
 Faulting package full name:
 Faulting package-relative application ID: }

💬 Zaldaryon , Dec 4th 2025, 10:34:24

Introdile I'll try to see if I can countour the situation releasing a minor version soon, but the issue is about the Toolsmith mod.

The problem is that OptiTime's GuiManager optimization patches OnFinalizeFrame which calls guiDialog.OnFinalizeFrame(dt) for all loaded GUIs. This eventually triggers PostRenderInteractiveElementsComposeInteractiveElementsComposeSlotOverlays. When Toolsmith patches ComposeSlotOverlays and there's a null slot or invalid index, it crashes.

You can report it to them.

I'll take a look–try to find the issue–but you seem to know more about IL and the JIT compiler than me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions