[krbdev.mit.edu #7860] libdb2 tests hang

Greg Hudson via RT rt-comment at krbdev.mit.edu
Tue Feb 18 00:58:55 EST 2014


At this point I am pretty sure that this is actually a compiler bug, 
because:

* I can't reproduce the problem with the head revision of gcc.

* With gcc 4.8.1, I was able to construct simplified test cases (like 
the attached file) which clearly don't have strict aliasing violations, 
and only take advantage of C99 6.3.2.3 paragraph 7.

I would speculate that in the attached test case, the gcc 4.8.1 
optimizer sees list dereferenced before the conditional, and ent->prev 
in the else clause, and erroneously concludes that if the two pointers 
are the same, a strict aliasing violation must have occurred and the 
behavior is undefined.  But since the dereference only happens when the 
pointers are not equal, that deduction is invalid.

As for TAILQ, the macros in db-queue.h appear to be free of any aliasing  
or type-punning issues.  More recent versions of queue.h (including the 
one we copied into include/k5-queue.h) define additional TAILQ functions 
including:

#define TAILQ_PREV(elm, headname, field) \
        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))

which is pretty clearly a strict aliasing violation since tqe_prev could 
point to the first member of an element structure rather than a list 
head.  Therefore, we should avoid using TAILQ_PREV, 
TAILQ_FOREACH_REVERSE, and TAILQ_FOREACH_REVERSE_SAFE if we want to 
avoid unpleasant surprises.  TAILQs aren't really designed for reverse 
iteration anyway.

I will adjust the commit message on my CIRCLEQ->TAILQ patch to reflect 
my belief that it's working around a compiler bug, and push it.

I will revert d21a86e47a7cda29225013e08d060095b94b2ee7 and make an 
alternate change to deal with special shell characters in the system 
dictionary, since the built-in word list is not long enough for all of 
the tests.


More information about the krb5-bugs mailing list