mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: valgrind problems
Date: Sun, 16 Jun 2013 19:40:08 +0200	[thread overview]
Message-ID: <20130616174008.GF6548@port70.net> (raw)
In-Reply-To: <1371398332.5692.108.camel@eris.loria.fr>

* Jens Gustedt <jens.gustedt@inria.fr> [2013-06-16 17:58:52 +0200]:
> yes, I think it is gcc+platform behavior. the C standard makes no
> guarantee that this
> 
>    if (*z) *z=0;
> 
> guarantees that *z is observably 0 afterwards. And the problem is not
> that *z could be UB (if size_t had traps) but that there is no
> guarantee that an undetermined value is stable between two reads (the
> first with that "if" and the second from the application that receives
> this).

there is no undefined/implementation defined behaviour there

as rich said in freestanding mode malloc is not special
(musl gets initialized memory from the system through syscalls
and are always well defined at that point)

as far as i can see in freestanding mode you can only get
indeterminate values in
- objects with automatic storage duration
- objects modified from a signal handler
- unnamed members of a structure
none of these apply to *z in calloc

but i think you are wrong about the if (*z) *z=0; more generally:

accessing objects with indeterminate value is not undefined
in general, at least the definition of 'indeterminate value'
does not allow that, unless it may be a trap representation:
http://port70.net/~nsz/c/c11/n1570.html#3.19.2p1

if it is intended to be undefined then the normative text should
say so

the only explicitly undefined case i see is
http://port70.net/~nsz/c/c11/n1570.html#6.3.2.1p2
but that does not apply to accessing objects through a pointer


  parent reply	other threads:[~2013-06-16 17:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-15 22:01 [PATCH] bugfix: initialize a state variable in lio_wait Jens Gustedt
2013-06-15 22:16 ` Szabolcs Nagy
2013-06-16  5:40   ` Rich Felker
2013-06-16  7:22     ` Jens Gustedt
2013-06-16  9:31       ` Jens Gustedt
2013-06-16 10:18         ` Justin Cormack
2013-06-16 10:43           ` valgrind problems Jens Gustedt
2013-06-16 11:39             ` Szabolcs Nagy
2013-06-16 14:16               ` Jens Gustedt
2013-06-16 14:36                 ` Rich Felker
2013-06-16 14:31             ` Rich Felker
2013-06-16 15:26               ` Jens Gustedt
2013-06-16 15:31                 ` Rich Felker
2013-06-16 15:58                   ` Jens Gustedt
2013-06-16 16:04                     ` Rich Felker
2013-06-16 17:39                       ` Jens Gustedt
2013-06-16 19:16                         ` Rich Felker
2013-06-16 19:38                           ` Szabolcs Nagy
2013-06-16 19:41                             ` Rich Felker
2013-06-16 17:40                     ` Szabolcs Nagy [this message]
2013-06-16 18:02                       ` Jens Gustedt
2013-06-16 19:25                         ` Szabolcs Nagy
2013-06-16 19:29                           ` Rich Felker
2013-06-16 14:24         ` [PATCH] bugfix: initialize a state variable in lio_wait Rich Felker
2013-06-16 15:48           ` Jens Gustedt
2013-06-16 15:37   ` Szabolcs Nagy

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=20130616174008.GF6548@port70.net \
    --to=nsz@port70.net \
    --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).