mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: [PATCH] missing volatile in __get_locale
Date: Sat, 24 Jun 2017 11:54:25 +0200	[thread overview]
Message-ID: <868874$8bedn9@mail2-relais-roc.national.inria.fr> (raw)

All int that are used with atomic operations, should be volatile.

The calls to __lock & Co hid this bug because they implicitly add the
qualifier to the target. But intelligent lto could have bitten us one
day.
---
 src/locale/locale_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c
index c3e59174..188fcf39 100644
--- a/src/locale/locale_map.c
+++ b/src/locale/locale_map.c
@@ -26,7 +26,7 @@ static const char envvars[][12] = {
 
 const struct __locale_map *__get_locale(int cat, const char *val)
 {
-	static int lock[2];
+	static volatile int lock[2];
 	static void *volatile loc_head;
 	const struct __locale_map *p;
 	struct __locale_map *new = 0;
-- 
2.11.0


             reply	other threads:[~2017-06-24  9:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-24  9:54 Jens Gustedt [this message]
2017-07-04 22:22 ` Rich Felker
2017-07-04 22:24   ` Alexander Monakov
2017-07-04 22:28     ` Rich Felker
2017-07-05  6:30       ` move to a proper __lock_t type Jens Gustedt
2017-07-05 16:07         ` Rich Felker
2017-07-05 20:53           ` Jens Gustedt
2017-07-05 21:41             ` Rich Felker
2017-07-06 14:33               ` Jens Gustedt

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='868874$8bedn9@mail2-relais-roc.national.inria.fr' \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).