gcc version and endless looping in ack_lease function

Bora Akyol (bora) bora at cisco.com
Mon Dec 8 20:39:51 UTC 2008


Hi,

In one of our products, we use dhcp-3.0.1. Recently we made the switch
from gcc4.0 to
gcc 4.02.

Soon after the switch we started running into an endless loop issue
which happens
as a rare event in the field.

We have traced the looping behavior to the following lines of code:

 if (lease -> uid_len) {
		do {
		    seek = (struct lease *)0;
		    find_lease_by_uid (&seek, lease -> uid,
				       lease -> uid_len, MDL);
		    if (!seek)
			break;
		    if (seek == lease && !seek -> n_uid) {
			lease_dereference (&seek, MDL);
			break;
		    }
		    next = (struct lease *)0;

		    /* Don't release expired leases, and don't
		       release the lease we're going to assign. */
		    next = (struct lease *)0;
		    while (seek) {
			if (seek -> n_uid)
			    lease_reference (&next, seek -> n_uid, MDL);
			if (seek != lease &&
			    seek -> binding_state != FTS_RELEASED &&
			    seek -> binding_state != FTS_EXPIRED &&
			    seek -> binding_state != FTS_RESET &&
			    seek -> binding_state != FTS_FREE &&
			    seek -> binding_state != FTS_BACKUP)
				break;
			lease_dereference (&seek, MDL);
			if (next) {
			    lease_reference (&seek, next, MDL);
			    lease_dereference (&next, MDL);
			}
		    }
		    if (next)
			lease_dereference (&next, MDL);
==>		    if (seek) {
			release_lease (seek, packet);
			lease_dereference (&seek, MDL);
		    } else
			break;
		} while (1);

Specifically, when we compile with 4.0.0 version of gcc, during
execution when the line 
marked by ==> is reached, the execution does not go into the body of the
if statement.

However, when compiled with 4.0.2, we see that the branch is taken and
we are in an endless loop.

I am not inclined to blame the compiler as typically, a compiler version
change exposes a problem in the original code.

I was wondering:

a) If this is a known problem.
b) Should the return code of some of these functions be checked for
error conditions
and seek set back to NULL.

Sorry for lack of detail, I was just handed this a few hours ago and I
did not get a chance to completely read and understand this body of
code.

Thanks

Bora




More information about the dhcp-hackers mailing list