From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B9F03877237; Tue, 13 Dec 2022 18:45:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B9F03877237 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670957132; bh=SJ7Py4hpvash5S75AfXs2JzZ+c1N3uShamg+/rVUAa0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YERKyfOf9oZaiulnci7ojMxdONSHPJFS/9RD/gMhw/JzBU/kuBDdyHggCFjUoXQRd gwtDH5hkq4tQ9kq1ybFwfU6qMNjAgsomxqk9wW2ZVgYo+lZYP/mUY3BtOfu9QyUcrA i1q95d+Bp82QudQM/eOvFoN+N7cnh9CJo1ta26V4= From: "nars at yottadb dot com" 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 18:45:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.36 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nars at yottadb dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29863 --- Comment #5 from Narayanan Iyer --- (In reply to Andrew Pinski from comment #4) > (In reply to Narayanan Iyer from comment #3)=20 > > More importantly this code works fine prior to glibc 2.36. It fails only > > with glibc 2.36. >=20 > On x86_64. My bet it fails on most other targets and always had failed. > The Seg fault is just saying you are violating atomicity. > It is not only a race condition but the race condition is inside memcmp > itself now since memcmp is not atomic for the whole length, it is a byte > wise comparison which can be read more than once so you just happen to run > into a bug in your code. > Having memcmp being atomicity and reading from the memory only once is ABI > thing really and x86_64 ABI does not talk about that. It just happened to > work on accident does not mean the behavior should go back to what it was. Seems to me you are saying that `memcmp()` can only be called on memory tha= t is guaranteed to be never changing. And that it should never be called on a sh= ared memory buffer whose contents could be concurrently changing as it goes into undefined behavior territory. That does not sound right to me as we have be= en using `memcmp()` with shared memory (where multiple processes write to that memory buffer all the time) for the past 25+ years on a variety of architectures and operating systems and have never once seen a SIG-11 in memcmp(). --=20 You are receiving this mail because: You are on the CC list for the bug.=