Ibn Ezra cryptically comments on Pinchas' killing of Zimri (25:7):
ויש בכאן שאלה.
"There is a question here," he says, but he doesn't tell us what it is. He does, however, give us the answer:
ויתכן להשיב שכבר נצמד זמרי בעדים
The footnotes of the Mossad haRav Kook edition of the Ibn Ezra explains that what bothered Ibn Ezra is that the text never mentions what this "ish Yisrael" did wrong -- all we know is that he brought a Midianite woman before Moshe and the people assembled in front of Ohel Moed. The answer is that the illicit act must have already taken place before Pinchas grabbed his spear, even though the text doesn't spell it out.
B'mechilas kvodam of the editor, I don't think that was the Ibn Ezra's question or the point of his answer.
Rambam writes (Issurei Bi’ah 12:4) that kan’im who kill someone who is bo’el aramis in public are deserving of praise for their zealousness, as we see from the actions of Pinchas. Ra’avad adds that this is true only if hasra’ah was given and the bo’el did not stop, otherwise this is not a praiseworthy act.
I think the Ibn Ezra held like the Ra'avad, and what bothered him is that Pinchas seems to act without pause, without taking time to give hasra'ah. Ibn Ezra therefore explains that there was witnesses present who saw what Zimri did. It is those witnesses (why else mention this detail?) who must have given the requisite hasra'ah.
What are the Rambam and Ra'avad arguing about? Magid Mishnah explains the issue at hand is whether kana’im pogim bo is a capital penalty like other misos beis din, or whether it is a unique chiddush din. According to Rambam, kana’im pogim bo is vigilante justice – it’s in a separate category from formal misas beis din. We are dealing with a unique halacha l’Moshe m’Sinai that can be carried out only at the scene and time of the crime, where guilt is clear and therefore no hasra’ah is required. Ra’avad, on the other hand, derives from Chazal (“haya lo lifrosh v’lo pireish”) that Pinchas did in fact warn Zimri; kana’im pogim bo is no different than any other chiyuv misas beis din which requires hasra’ah. It's just carried out by an individual instead of the court.
If this approach is correct, the Ra’avad severly understates his case. Failure to give hasra’ah shouldn’t just mean “lo amrinan harei eilu m’shubachin,” that the vigilante is not deserving of praise. It should mean the vigilante has in effect committed murder, because without hasra’ah there is no license to kill the bo’el!
R’ Shimon Moshe Diskin explains that even according to Ra’avad, kana’im pogim bo is a unique din, categorically different than misas beis din. The reason the Ra'avad requires hasra’ah is because kana’im pogim bo is a halacha v’ain morin kein – it’s something to be avoided, not encouraged. Killing is permissible in this case, but it should be seen as a last resort, undertaken only when all other options, including issuing a verbal warning, have failed. By way of analogy, he quotes the view of the Ramah that hasra’ah has to be given to a rodef before more violent action can be taken to stop him. It’s not because killing a rodef is like misas beis din – it’s because killing the rodef is a last resort. The gemara says if the rodef can be stopped by breaking an arm or leg, then there is no license to kill. Surely it follows that if yelling a hasra'ah warning to the rodef, "Stop or I'll shoot!" will get him to stop, killing would be an excess.
What bothers me is that if that is the case, why did Pinchas have to kill Zimri? Why couldn't he have just pushed him aside, or taken some other action to stop him?