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

Re: test008 failed in HEAD



A valid suggestion, but I'll note that I'm seeing similar failures with Sun Studio on sparc and no optmization. That's pretty far off from gcc...

On Tue, 4 Dec 2007, Hallvard B Furuseth wrote:

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;
into
  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
compiler.

--
Regards,
Hallvard