I have a ethereum smart contract online. There is a function anyone can execute. In fact it's a bug, then there is a guy always execute the function successfully and rapidly with low gas, while my transaction is always reverted even with higher gas. It seems that the guy has a priority and higher speed to execute the function. How did this happen? And how should i solve this issue? I use ethers.js as client lib. Thanks very much.
It's not possible to explain why a contract behaves the way it does without examining the source code. You say "it's a bug", so I'm guessing you've seen it?
Things are not always what they seem. People and software don't always play nice. There is a particularly nasty kind of software called a "honeypot". These things are designed to trick people into thinking they do one thing when, in fact, they do something else.
If you find yourself sending it funds and getting a surprising result it might be best to pause for moment and post a link to the code so the experts here can help you figure out what's going on.
Hope it helps.