in its history.
We currently have a Pope whose allies, the so called St. Gallen Mafia, violated the papal decree outlining the rules for the election which elevated him to the office.
There are also some who claim that Pope Benedict had been pressured into resigning which would invalidate his resignation. He also still dresses as Pope and uses the title of Pope Emeritus. St. Francis, on the other hand has rejected the title, Vicar of Christ.
Saints have speculated about whether a pope who became a heretic would automatically cease to be pope. The conclusion seems to be that yes, he would thereby no longer be pope. Multiple priests and theologians have already publicly called him out as a heretic, and he does little to try and dispel their concerns, but plunges on ahead with his destructive plans anyway.
We even had a pope, Pope Honorius, who was condemned as a heretic by 3 ecumenical councils and every pope from the 8th to the 11th century. It was not because he was teaching heresy, but because he did nothing to stop it.
https://www.newadvent.org/cathen/07452b.htm
In what sense Honorius was condemned
..the decree of the council itself: "We anathematize the inventors of the new error, that is, Theodore, Sergius, ...and also Honorius, who did not attempt to sanctify this Apostolic Church with the teaching of Apostolic tradition, but by profane treachery permitted its purity to be polluted."...
"With Honorius, who did not, as became the Apostolic authority, extinguish the flame of heretical teaching in its first beginning, but fostered it by his negligence."
Pope Honorius was subsequently included in the lists of heretics anathematized by the Trullan Synod, and by the seventh and eighth ecumenical councils without special remark; also in the oath taken by every new pope from the eighth century to the eleventh in the following words: "Together with Honorius, who added fuel to their wicked assertions" (Liber diurnus, ii, 9).