Skip to content

HuntManager.OnBotCreated throws unhandled NRE for a foreign bot, aborting another mod's spawn (Fika headless) #5

Description

@jbo3320

Summary

HuntManager.OnBotCreated throws an unhandled NullReferenceException when it processes a bot that was created by another mod (MiyakoCarryService's "carry" companion bot). Because MoreBotsAPI hooks OnBotCreated globally and the exception is not guarded, it propagates back up through the bot-created callback chain and aborts that third-party mod's spawn — the carry bot fails to spawn intermittently on a Fika headless host.

In other words: a bot MoreBotsAPI doesn't own can make MoreBotsAPI's global hook throw, and that throw takes down an unrelated spawn.

Environment

Component Version
MoreBotsAPI 2.0.1 (latest)
MiyakoCarryService 1.0.12.0 (latest)
Fika.Core 2.3.7 — host is a headless / dedicated server
SPT 4.0.13
EFT 0.16.9.0.40087

Exception (headless server log — thrown during another mod's spawn)

EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at MoreBotsAPI.Components.HuntManager.OnBotCreated (EFT.BotOwner bot) [0x0000c] in <a72721ada2ef4c87a44f1c4d6149895a>:0
  at EFT.BotSpawner.method_11 (EFT.BotOwner bot, BotCreationDataClass data, System.Action`1[T] callback, System.Boolean shallBeGroup, System.Diagnostics.Stopwatch stopWatch) [0x000ce] in <ad47400a25db462cbf0a531df654c3c3>:0
  at MiyakoCarryService.Client.GameLoop+<>c__DisplayClass46_3.<SpawnMcsBotPlayer>b__7 (EFT.BotOwner botOwner) [0x0004b] in <48a71ffd133c45148b05430351aca73f>:0
  at BotCreatorClass.method_3 (BotZone zone, EFT.BotOwner bot, System.Action`1[T] callback, System.Func`3[T1,T2,TResult] groupAction) [0x0008a] in <ad47400a25db462cbf0a531df654c3c3>:0
  at BotCreatorClass+Class563.method_0 (EFT.BotOwner bot) [0x00000] in <ad47400a25db462cbf0a531df654c3c3>:0
  at BotCreatorClass.method_2 (EFT.Profile profile, GClass682 bornInfo, System.Action`1[T] callback, System.Boolean isLocalGame, System.Threading.CancellationToken cancellationToken) [0x00127] in <ad47400a25db462cbf0a531df654c3c3>:0

Analysis

  • Ordinary bots (scavs / PMCs) pass through HuntManager.OnBotCreated fine. In the affected raids the NRE fired only for the MiyakoCarryService carry bot — a synthetic "player-like" bot. This strongly suggests HuntManager dereferences a field at offset 0x0000c (a role / profile / owner field) that is null for a bot HuntManager didn't create and doesn't track.
  • It is intermittent, consistent with the null path depending on HuntManager's internal state at spawn time.
  • Both mods are on their latest versions, so it isn't resolved upstream on either side.

Suggested fix

A defensive guard in HuntManager.OnBotCreated — early-return (or try/catch) for any BotOwner MoreBotsAPI didn't create / doesn't track, instead of dereferencing fields that may be null for foreign bots. Since this is a global OnBotCreated hook, an unhandled throw here can break spawns owned by completely unrelated mods, so failing safe for unknown bots would prevent that collateral damage.

For context, the 2.0.1 changelog notes "removed excessive client logging caused by hunt behaviors" — this appears to be the same hunt code path.

Cross-reference

Reported in parallel to MiyakoCarryService: himesamanoyume/MiyakoCarryService#10

Happy to provide full client + headless logs.

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