Say my router has two interfaces (eth0 and eth1). The default entry in the routing table uses eth0. Now if the router gets a packet on eth0 and the dst IP does not match any entry in routing table, it will send the packet back on the default route. This will lead to a routing loop. How does a router avoid this? Does it realize this and send a ICMP destination unreachable (type 3, code 0) message. In general does a router ever forward a packet to the same interface on which it was received?
IP datagrams have a "Time To Live" (TTL) value in the IP header. Each time a router forwards a datagram, it decrements (subtracts 1 from) the TTL. When the TTL reaches zero, the router drops (deletes, does not forward) the datagram, and sends back an ICMP "Destination Unreachable, TTL Exceeded" message.
Also, when your router got a packet from a host on eth0 that would have been better delivered to another host or via another router that was also on the data-link layer network (in this case, the Ethernet LAN) out eth0, it could send an ICMP Redirect message to inform the local host that sent that packet that it should really have sent it directly to that other host or router on the same Ethernet LAN.
Overall, routing loops are avoided through good network design, and through using route advertisement protocols and route table maintenance procedures that avoid loops.
First, ALL routers by definition have multiple interfaces.
Second, the router should not normally even receive something it has to spit back out on the same interface.
If you are sending traffic to a router that it shouldn't be routing, something is not setup correctly in that host (maybe DHCP handed out the wrong default gateway, IP address/network mask not set correctly, etc.)
As @Spiff said this is why there's a TTL.
Routing loops are typically a bigger problem when you have more than two interfaces and more than one router in a subnet. Routing protocols such as RIP, IGRP, EIGRP, OSPF, and BGP are used between routers to work things out such as who is routing for a subnet, who's the backup, and to track when routers are no longer reachable.