The reason that HAL tries to everyone in the first place is that he has been given conflicting programming. As we see at the start of the film, evidence of intelligent life has been discovered in the form of a monolith buried on the Moon. The mission to Jupiter has a secret purpose of investigating this further. The secrecy is so great that only HAL knows about it, and he's been ordered to maintain this secrecy at all costs. This is revealed in a recorded message just after Dave completes the procedure of deactivating HAL.
In the book it is revealed that HAL's behaviour is ultimately the result of this order. Killing them is simply a logical way to avoid having to tell them the true purpose of the mission. At first he merely fabricates a fault in the communication system in order to keep his options open, but then the astronauts start to discuss deactivating him. Since this would would jeopardise the secret mission he has no logical choice but to eliminate them. Although the book and the film differ in many details and can't really be considered part of the same canon, I think something of this does come across in the film, at least if you know it's there and go looking for it.
So in this interpretation HAL did not have any logic errors, but rather the problem was human error in giving him a secrecy order that outweighed the importance of the human lives on the ship. There is nothing that HAL could have fixed after Bowman re-entered the ship; he would have continued correctly implementing the orders he was given, which at that point would have meant killing Dave Bowman some other way, after which he would have carried out the scientific part of the mission on his own.