public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* BZ 20822 :powerpc: race condition in __lll_unlock_elision
@ 2016-11-15 16:13 Rajalakshmi Srinivasaraghavan
  2016-11-16 13:40 ` Adhemerval Zanella
  2016-11-17 14:47 ` Torvald Riegel
  0 siblings, 2 replies; 22+ messages in thread
From: Rajalakshmi Srinivasaraghavan @ 2016-11-15 16:13 UTC (permalink / raw)
  To: libc-alpha
  Cc: aaron Sawdey, Ulrich Weigand, Steve Munroe, carlos,
	adhemerval.zanella, adconrad, wschmidt


The initial problem reported was memory corruption in MongoDB only on 
Ubuntu 16.04 ppc64le(not on Ubuntu 15).
The problem was not easily recreatable and debugging with many tools and 
creative ideas, the problem is narrowed down to lock elision in glibc.
Ubuntu 16.04 has glibc 2.23 with lock elision enabled by default which 
made the testcase fail only on 16.04.

As stated in BZ 20822, short description is

"The update of *adapt_count after the release of the lock causes a race 
condition. Thread A unlocks, thread B continues and returns, destroying 
mutex on stack,
  then gets into another function, thread A writes to *adapt_count and 
corrupts stack.The window is very narrow and requires that the
machine be in smt mode, so likely the two threads have to be on the same 
core in order to hit this"

Looking back the file changes in 
sysdeps/unix/sysv/linux/powerpc/elision-unlock.c, suspecting the commit
  https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fadd2ad9cc36115440d50b0eae9299e65988917d which is introduced to improve
the performance.

Thinking of the following fixes.

1) Update of adapt_count before the unlock. But I have still not 
identified if its going to affect the performance.

2) In elision-lock.c/elision-trylock.c update adapt_count right after 
the lock acquire at the end of the function.
In either case we have to be careful not to introduce another race 
condition.

Any suggestions?

-- 
Thanks
Rajalakshmi S

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-12-04 12:14 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 16:13 BZ 20822 :powerpc: race condition in __lll_unlock_elision Rajalakshmi Srinivasaraghavan
2016-11-16 13:40 ` Adhemerval Zanella
2016-11-16 14:08   ` Szabolcs Nagy
2016-11-16 14:31     ` Adhemerval Zanella
2016-11-16 15:54       ` Rajalakshmi Srinivasaraghavan
2016-11-17 14:47 ` Torvald Riegel
2016-11-21 23:42   ` Steven Munroe
2016-11-22  8:44     ` Torvald Riegel
2016-11-22  8:55       ` Florian Weimer
2016-11-22  9:41         ` Torvald Riegel
2016-11-22 10:52           ` Florian Weimer
2016-11-22 13:45             ` Torvald Riegel
2016-11-22 15:02               ` Florian Weimer
2016-11-22 16:58                 ` Torvald Riegel
2016-11-22 18:40                   ` Informal model for transactional memory (was: Re: BZ 20822 :powerpc: race condition in __lll_unlock_elision) Florian Weimer
2016-11-22 20:15                     ` Steven Munroe
2016-11-23 14:29                     ` Torvald Riegel
2016-11-22 18:03       ` BZ 20822 :powerpc: race condition in __lll_unlock_elision Steven Munroe
2016-11-23 11:30         ` Torvald Riegel
2016-11-23 17:02           ` Steven Munroe
2016-11-23 18:35             ` Torvald Riegel
2016-12-04 12:14   ` Torvald Riegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).