Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EpicLoot 0.7.6] crash when attacking deer #137

Closed
maxrd2 opened this issue Apr 15, 2021 · 13 comments
Closed

[EpicLoot 0.7.6] crash when attacking deer #137

maxrd2 opened this issue Apr 15, 2021 · 13 comments
Assignees
Labels
bug Something isn't working EpicLoot

Comments

@maxrd2
Copy link
Contributor

maxrd2 commented Apr 15, 2021

Crash is happening on Linux version of the game.

Without Epic Loot mod crash isn't happening. Tested without other mods installed.

Steps to reproduce:

  1. Equip melee/ranged weapon (tried normal Bow, Flint Axe and magic Club)
  2. Attack any Deer
  3. Game crashes

Here's the stack trace from Player.log.

Caught fatal signal - signo:4 code:2 errno:0 addr:0x40a0b5d9
Obtained 25 stack frames.
#0  0x00000040a0b5d9 in (Unknown)
#1  0x00000040b9ea52 in (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___long_object (object,intptr,intptr,intptr)
#2  0x007f31852d9715 in mono_print_method_from_ip
#3  0x007f31854491cc in mono_perfcounter_foreach
#4  0x007f3185451287 in mono_runtime_run_main
#5  0x007f3185413cf4 in mono_install_unhandled_exception_hook
#6  0x000000407e49d1 in (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
#7  0x000000407e359b in System.Reflection.MethodBase:Invoke (object,object[])
#8  0x00000040bc2794 in Attack:OnAttackTrigger ()
#9  0x007f31852d9715 in mono_print_method_from_ip
#10 0x007f31854491cc in mono_perfcounter_foreach
#11 0x007f318544a079 in mono_runtime_invoke
#12 0x007f32601047e2 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#13 0x007f3260102b9a in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#14 0x007f325f8cc8dd in FireEvent(AnimationEvent&, Unity::Component&, AnimationState*, AnimatorStateInfo*, AnimatorClipInfo*)
#15 0x007f326051f96d in AnimationClip::FireAnimationEvents(AnimationClipEventInfo*, Unity::Component&)
#16 0x007f325f899472 in Animator::FireAnimationEvents(Animator::AnimatorJob&)
#17 0x007f325f897de7 in Animator::UpdateAvatars(dynamic_array<PlayableOutput*, 0ul> const&, bool, bool, bool)
#18 0x007f32600d68bf in DirectorManager::InitializeClass()::FixedUpdateDirectorFixedUpdateRegistrator::Forward()
#19 0x007f325ffbf23e in ExecutePlayerLoop(NativePlayerLoopSystem*)
#20 0x007f325ffbf281 in ExecutePlayerLoop(NativePlayerLoopSystem*)
#21 0x007f325ffbf7ba in PlayerLoop()
#22 0x007f326015ca94 in PlayerMain(int, char**)
#23 0x007f325f28fb25 in __libc_start_main
#24 0x00000000400569 in _start

Player.log

@maxrd2 maxrd2 changed the title Epic Loot 0.7.6 - crash when attacking deer with flint axe [EpicLoot 0.7.6] crash when attacking deer with flint axe Apr 15, 2021
@maxrd2 maxrd2 changed the title [EpicLoot 0.7.6] crash when attacking deer with flint axe [EpicLoot 0.7.6] crash when attacking deer Apr 16, 2021
@maxrd2
Copy link
Contributor Author

maxrd2 commented Apr 17, 2021

Crash was introduced with a16a4c2. Will try to figure it out and submit PR if that's ok.

@RandyKnapp
Copy link
Owner

👍

@maxrd2
Copy link
Contributor Author

maxrd2 commented Apr 17, 2021

After a bit of testing/debugging have found culprit here:

public static class AddLifeSteal_Character_OnDamaged_Patch

If I remove Character.OnDamaged patch the crash goes away.
I've heard from some other unity3d modder that there is a problem in mono on Mac/Linux when patching empty/virtual methods.
I believe this is related to pardeike/Harmony#57 and probably crash is happening on both Mac/Linux.

dnSpy shows Character.OnDamaged like this:

// Character
// Token: 0x06000041 RID: 65 RVA: 0x000027E0 File Offset: 0x000009E0
protected virtual void OnDamaged(HitData hit)
{
}

and Humanoid.OnDamaged like this:

// Humanoid
// Token: 0x06000115 RID: 277 RVA: 0x000084B5 File Offset: 0x000066B5
protected override void OnDamaged(HitData hit)
{
	this.SetCrouch(false);
}

It seems that Humanoid.OnDamaged() patch is not causing crashes.

Any ideas? I have like zero experience with C#, Harmony, Mono and co. Will try to google some more and maybe try using [HarmonyPrefix] instead of Postfix patch.

@RandyKnapp
Copy link
Owner

Thanks so much, awesome code-sleuthing! You could patch the method that calls OnDamaged?

@RandyKnapp
Copy link
Owner

@maxrd2 This should be fixed since I merged your change. It will go out in the next release, but since I don't have access to a linux box, could you test it?

@WillowMist
Copy link

I can test this out when I get home. I've got a deer trapped in my fortress, that I've been able to consistently crash the game with.

@SuntooX
Copy link

SuntooX commented Apr 26, 2021

Sorry for the stupid question but I'd love to help out and test this as well on my box - how does one assemble the dll/json formats from the cs and folders...
I just do R, and R doesn't hurt my feelings like C++

@maxrd2
Copy link
Contributor Author

maxrd2 commented Apr 26, 2021

I've compiled it with free Visual Studio on windows virtual machine, so am not sure how to do it on Mac/Linux. This one is C# not C++

@maxrd2
Copy link
Contributor Author

maxrd2 commented Apr 26, 2021

Just tried and can confirm that issue is solved on main branch now

@WillowMist
Copy link

Looking forward to trying this with the next release. Realized a bit late I don't have the tools easily available to compile it myself. :)

@SuntooX
Copy link

SuntooX commented Apr 27, 2021

Just tried and can confirm that issue is solved on main branch now

By any chance, could you compile and upload the complete package, please?
I tried to do the assembly within my box and honestly could not figure out how to handle the unity dependencies for my life...

If you can't or don't want to thats fine. But Im excited about the adventuring and want to try it out!

@RandyKnapp
Copy link
Owner

@SuntooX The release version is available here: https://www.nexusmods.com/valheim/mods/387

@SuntooX
Copy link

SuntooX commented Apr 27, 2021

@SuntooX The release version is available here: https://www.nexusmods.com/valheim/mods/387

You are fantastic and my day is made. Thank you <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working EpicLoot
Projects
None yet
Development

No branches or pull requests

4 participants