2 handed weapon grab gimbal lock

I’m trying to implement 2 handed weapons where the primary motion controller is attached to the weapon and I use a look at rotation to make the weapon look towards the second hand.

This is all working quite well but there are a few issues when aiming upwards or downwards where the weapon will twist and roll around its X axis.

I’ve tried various versions trying to not use Rotators and only use quaternions. I’ve tried calculating both axis separately and combining them but I haven’t managed to get a solution that work when holding the weapon in all direction. E.g. Firing downwards, upwards, blind firing behind my head

Does anyone have and ideas or solutions they’ve found? Anyone have a solution for two handed weapons were the weapon doesn’t spin or twist unnaturally at the poles?

I’ll post some examples I’ve tried

Example 1
FRotator AimAtRotation = UKismetMathLibrary::FindLookAtRotation(AimFromLocation, AimAtPosition);
MeshComponent->SetWorldRotation(FRotator(AimAtRotation.Pitch, AimAtRotation.Yaw, AimFromRotation.Roll));

    
Example 2
auto LocalAimAt = PivotComponent->GetComponentTransform().InverseTransformPosition(AimAtPosition);
auto LocalUpVector = PivotComponent->GetComponentTransform().InverseTransformPosition(FVector::UpVector);
auto Orientation = FRotationMatrix::MakeFromXZ(LocalAimAt - FVector::ZeroVector, LocalUpVector).ToQuat();
MeshComponent->SetRelativeRotation(Orientation);

I haven’t tried using UPhysicsHandleComponent’s yet (instead of just attaching) as it sounds like there the weapon could lag behind the motion controller.