Debugging "The given account is not owned by the executing program"

I’m suddenly getting this error and have no idea how to debug it.

Is there any way to find out what “the given account” refers to, who the owner is and who is currently trying to do something which is not allowed?

Is this on a program that you have written?

I don’t know if there’s a way to figure out exactly which account it’s talking about, but I usually put msg!() lines in the contract to log points in the program to find out exactly which line is causing the error, and that often helps.

Could you share maybe a snippet of the code for what you are trying to do?