Unlock order makes a difference since it is a thread's externally
visible behavior. It doesn't make a difference as to the logical
existence of a deadlock (if that's the problem you're thinking of). The
unlock operations are monotonically increasing freedom by releasing
resources.
Suppose different sets of threads are waiting on or contending for locks
a and b. Unlocking 'a' first interacts with one set. Unlocking 'b' first
interacts with the other set.
Any behavior change, even if itself correct, can conceivably "tickle" a
some latent bug whose root cause is actually elsewhere.
That is to say, suppose some sort of bug exists (that doesn't depend on
the order of those two unlocks) but is somehow exposed by changing the
order.
(Of course, if there is such an issue, of course we want to *know*;
we just, if possible, don't want to learn about it from a user having
a problem in the field.)
Basically similar reasoning applies as to:
free(a);
free(b);
is there any difference in the order in which we free two objects to the
allocator? Of course, either order is correct, but it *can* make some
sort of difference (even in a single-threaded program) by interacting
with a (use-after-free bug) --- when a situation is incorrect in the
program as a whole, involving those objects.