Skip to content

NRE in Pawn_DrawTracker_Patch.Postfix #113

Open

Description

@bonesbro

Crash looks like it's related to 21305e @RedMattis

The IL offset is 0x0066 which, decompiled, is this code:

// __result.z += threadStaticCache.cache.renderPosOffset;
IL_0065: nop
IL_0066: ldarg.0
IL_0067: ldflda float32 [UnityEngine.CoreModule]UnityEngine.Vector3::z
IL_006c: dup

My IL is pretty rusty, but I think that ldarg.0 followed by the reference to the vector z indicates that the NRE is because __result is null.

Haven't done much investigation to find a less specific repro case, but in this case it was casting a particular spell (Summon Spirit Wolves) from the Rimworld of Magic mod. Whatever, super niche, but I hope the details are enough to help.

Slightly truncated call stack:
Exception ticking Rhino (at (128, 0, 176)): System.NullReferenceException: Object reference not set to an instance of an object
[Ref 5885F667]
at VFECore.Pawn_DrawTracker_Patch.Postfix (UnityEngine.Vector3& __result, Verse.Pawn ___pawn) [0x00066] in <1b1b05ff0320402bacdfe2a192f60d1f>:0
at Verse.Pawn_DrawTracker.get_DrawPos () [0x00066] in <2a40c3593b334f29ac3cb3d32d652351>:0
- POSTFIX OskarPotocki.VFECore: Void VFECore.Pawn_DrawTracker_Patch:Postfix(Vector3& __result, Pawn ___pawn)
at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.Glue:AbiFixup<UnityEngine.Vector3 Verse.Pawn_DrawTracker:get_DrawPos(),UnityEngine.Vector3 Verse.Pawn_DrawTracker.get_DrawPos_Patch2(Verse.Pawn_DrawTracker)>(Verse.Pawn_DrawTracker,UnityEngine.Vector3&)
at Verse.Pawn.get_DrawPos () [0x00006] in <2a40c3593b334f29ac3cb3d32d652351>:0
at TorannMagic.Verb_SummonSpiritWolves.TryCastShot () [0x00224] in <4398f2df9b1046ebb8ad25082d7ee8a8>:0
at Verse.Verb.TryCastNextBurstShot () [0x00030] in <2a40c3593b334f29ac3cb3d32d652351>:0
- TRANSPILER Tacticowl: IEnumerable1 Tacticowl.Verb_TryCastNextBurstShot:Transpiler(IEnumerable1 instructions)
- TRANSPILER legodude17.mvcf: IEnumerable1 MVCF.PatchSets.PatchSet_VerbComps:TryCastNextBurstShot_Transpiler(IEnumerable1 instructions, ILGenerator generator)
- POSTFIX legodude17.mvcf: Void MVCF.PatchSets.PatchSet_VerbComps:TryCastNextBurstShot_Postfix(Verb __instance)
- POSTFIX latta.infusion: Void Infusion.Harmonize.Verb+TryCastNextBurstShot:Postfix(Verb __instance)
- POSTFIX Torann.ARimworldOfMagic: Void TorannMagic.TorannMagicMod+TryCastNextBurstShot_Monk_Patch:Postfix(Verb __instance, LocalTargetInfo ___currentTarget, Int32 ___burstShotsLeft)
at AbilityUser.Verb_UseAbility.WarmupComplete () [0x0002c] in <6cf731d104ea4d4fa7399ead3bf256f1>:0
at Verse.Stance_Warmup.Expire () [0x0000a] in <2a40c3593b334f29ac3cb3d32d652351>:0
at Verse.Stance_Busy.StanceTick () [0x0002a] in <2a40c3593b334f29ac3cb3d32d652351>:0

Activity

  1. erdelf commented on Oct 29, 2024

    @erdelf
    Contributor

    __result can't be null actually.

    Full log please for clarity. Also gonna take a wild guess and say those Wolves don't have needs ?

  2. TorannD commented on Oct 31, 2024

    @TorannD

    They do have needs, but I don't think that's the issue. Here's the full logs:
    https://gist.github.com/HugsLibRecordKeeper/1560e83c925650e25940d2692a42a780

    The error is being generated by a call to pawn.DrawPos immediately after the pawn is spawned and done so to create a mote.
    FleckMaker.ThrowSmoke(animal.DrawPos, map, Rand.Range(.5f, 1.1f));

    Removing VFE and adding in logs to check for null values....

    Log.Message("animal.DrawPos: " + animal.DrawPos);
    Log.Message("map: " + map);
    FleckMaker.ThrowSmoke(animal.DrawPos, map, Rand.Range(.5f, 1.1f));
    

    Output from the log messages doesn't show any null values: https://gist.github.com/HugsLibRecordKeeper/509c65893c754d13f0eb38d6ea17d3c3

    animal.DrawPos: (89.5, 8.1, 121.5)
    map: Map-0-PlayerHome

    I've switched the position to use animal.Position.ToVector3Shifted() which doesn't generate any errors with VFE.

    Hope this helps identify the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions