[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: test008 failed in HEAD

If you are using gcc, it might help to compile BDB and/or OpenLDAP
without -O and see if that helps.  The gcc mailinglist and
comp.programming.threads recently discussed a some gcc optimizations
that are invalid for threaded code.   E.g. gcc can turn things like

<static or extern> int v;
   if (set_v()) v += 1;
   flag1 = (set_v() != 0);
   reg2 = v;
   reg2 += flag1;
   v = reg2;

If set_v() does trylock(lock protecting v) and returns true at success,
this breaks thread safety when set_v() fails.

The optimization is valid as far as the C standard is concerned, but
POSIX forbids it for threaded code.  Otherwise one would have to
sprinkle 'volatile' all over a threaded program, to protect it from the