This patch negates the effects of shear in the Copy Rotation constraint, which causes incorrect results and even flipping on rare occasions.
Here is the bug report associated with the issue: T80970
This bug report has an example of the problem in a .blend file.
This patch will change existing .blend files if a copy rotation constraint is used with a target that has shearing -- instead of pointing in the "wrong" direction (due to the shear), the constrained object will copy the final rotation of the target, with the shearing applied.
Proposed Solution: Correct the matrix of the constraint target for shear. Use the Y axis as the main axis, because it is the main axis of bones. And bones are the primary use-case for constraints.
Limitations of proposed solution:
It's conceivable that someone has used the "incorrect behavior" in a rig... although I doubt this. It may be necessary to create an "allow shear" checkbox that is disabled by default to maintain the legacy behavior.
No UI changes are needed for this patch :)