public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nars at yottadb dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/29863] Segmentation fault in memcmp-sse2.S if memory contents can concurrently change
Date: Tue, 13 Dec 2022 20:46:01 +0000	[thread overview]
Message-ID: <bug-29863-131-J157ZhIyQn@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29863-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29863

--- Comment #11 from Narayanan Iyer <nars at yottadb dot com> ---
(In reply to Noah Goldstein from comment #10)

> Out of curiosity what is the use-case that causes this to happen? Is it
> idiomatic in some way?
> 
> I'm unhappy that the code causes a SIG-11 in this case, but changing
> it to harden against this case is not free for correct usage performance
> so I'm not really convinced it's worth supporting this buggy usage unless
> this bug is common to some idiomatic schema (although even then, I'm not
> sure whether we could harden the entire string/mem library to that
> usage or even what changes that would imply).

We implement a database called YottaDB. It uses optimistic concurrency control
(also known as OCC) to implement transaction processing. See
https://en.wikipedia.org/wiki/Optimistic_concurrency_control for more details.

Every process that is in a transaction reads database values (from shared
memory) without holding a lock and tentatively prepare the needed changes in
private memory. To do this, it needs to examine shared memory contents and it
is here that we do the `memcmp()` calls which ended up with a SIG-11.

At the end of the transaction, we grab a lock and see if anything changed since
we started the transaction and if not we proceed to commit. If we notice
something changed, we restart the transaction. We minimize the use of locks
using this approach to get faster transaction throughput.

As I had mentioned in a previous comment, this model has been in use by us for
the past 25+ years in various architectures (x86_64, i386, RS6000, Alpha, VAX,
Sparc, HPPA etc.) and operating systems (Linux, AIX, Tru64, Solaris, HPUX etc.)
and has never caused a SIG-11 until now (i.e. glibc 2.36).

As you can see in the `Examples` section of the wikipedia link I mention above,
there are a lot of databases that use OCC. It is likely all of them use similar
techniques and are affected as well.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-12-13 20:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 10:49 [Bug libc/29863] New: " nars at yottadb dot com
2022-12-12 13:02 ` [Bug libc/29863] " nars at yottadb dot com
2022-12-13 18:26 ` pinskia at gcc dot gnu.org
2022-12-13 18:28 ` pinskia at gcc dot gnu.org
2022-12-13 18:33 ` nars at yottadb dot com
2022-12-13 18:39 ` pinskia at gcc dot gnu.org
2022-12-13 18:45 ` nars at yottadb dot com
2022-12-13 18:52 ` pinskia at gcc dot gnu.org
2022-12-13 19:13 ` goldstein.w.n at gmail dot com
2022-12-13 19:36 ` bhaskar at yottadb dot com
2022-12-13 20:09 ` goldstein.w.n at gmail dot com
2022-12-13 20:18 ` goldstein.w.n at gmail dot com
2022-12-13 20:46 ` nars at yottadb dot com [this message]
2022-12-13 21:09 ` hjl.tools at gmail dot com
2022-12-13 21:53 ` bhaskar at yottadb dot com
2022-12-13 23:01 ` goldstein.w.n at gmail dot com
2022-12-13 23:16 ` nars at yottadb dot com
2022-12-13 23:39 ` goldstein.w.n at gmail dot com
2022-12-14  0:14 ` goldstein.w.n at gmail dot com
2022-12-14  7:45 ` sam at gentoo dot org
2022-12-14 15:40 ` nars at yottadb dot com
2022-12-14 18:17 ` nars at yottadb dot com
2023-05-14 21:46 ` ppluzhnikov at google dot com
2023-05-14 21:48 ` ppluzhnikov at google dot com
2023-05-14 21:49 ` ppluzhnikov at google dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29863-131-J157ZhIyQn@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).