Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch > #33460 > unrolled thread

Help with a Mill-team internal discussion re preclusion of nasal demons?

Started byIvan Godard <ivan@millcomputing.com>
First post2016-02-03 14:59 -0800
Last post2016-02-04 10:05 -0800
Articles 20 — 8 participants

Back to article view | Back to comp.arch


Contents

  Help with a Mill-team internal discussion re preclusion of nasal demons? Ivan Godard <ivan@millcomputing.com> - 2016-02-03 14:59 -0800
    Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Noob <root@127.0.0.1> - 2016-02-04 09:07 +0100
      Re: Help with a Mill-team internal discussion re preclusion of nasal demons? rpw3@rpw3.org (Rob Warnock) - 2016-02-04 10:20 +0000
        Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Noob <root@127.0.0.1> - 2016-02-04 13:46 +0100
          Re: Help with a Mill-team internal discussion re preclusion of nasal demons? rpw3@rpw3.org (Rob Warnock) - 2016-02-04 14:06 +0000
      Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 10:30 +0000
        Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Noob <root@127.0.0.1> - 2016-02-04 13:55 +0100
          Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 14:52 +0000
            Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Noob <root@127.0.0.1> - 2016-02-04 16:28 +0100
              Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 16:38 +0000
    Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 10:40 +0000
      Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Ivan Godard <ivan@millcomputing.com> - 2016-02-04 02:58 -0800
        Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 12:20 +0000
          Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Ivan Godard <ivan@millcomputing.com> - 2016-02-04 09:34 -0800
            Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 18:25 +0000
        Re: Help with a Mill-team internal discussion re preclusion of nasal demons? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-02-04 12:46 +0000
        Re: Help with a Mill-team internal discussion re preclusion of nasal demons? MitchAlsup <MitchAlsup@aol.com> - 2016-02-04 06:43 -0800
          Re: Help with a Mill-team internal discussion re preclusion of nasal demons? nmm@wheeler.UUCP (Nick Maclaren) - 2016-02-04 14:49 +0000
    Re: Help with a Mill-team internal discussion re preclusion of nasal demons? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-04 13:18 +0000
    Re: Help with a Mill-team internal discussion re preclusion of nasal demons? timcaffrey@aol.com - 2016-02-04 10:05 -0800

#33460 — Help with a Mill-team internal discussion re preclusion of nasal demons?

FromIvan Godard <ivan@millcomputing.com>
Date2016-02-03 14:59 -0800
SubjectHelp with a Mill-team internal discussion re preclusion of nasal demons?
Message-ID<n8u0jv$4tl$1@dont-email.me>
This note is about an ongoing and as yet unsettled internal discussion 
about how the Mill should view the program/programmer/compiler/language 
relationship as it impacts the architecture and toolset design.

Anyone reading here is aware of the "nasal demon" controversy: that 
compilers may assume that formally undefined behavior does not appear in 
a program, and in consequence deduce conclusions and emit code (AKA 
nasal demons) that are surprising to the programmer. The Mill has chosen 
to be acutely security-conscious as part of its market positioning, and 
some of the "surprising" demons have led to security violations.

As part of its security focus, the Mill hardware guarantees that a 
program can only inspect its currently active stack frames, and that 
each newly allocated stack frame is implicitly initialized to zero. It 
is impossible for a Mill application to browse in the rubble left behind 
by previously-called functions or interrupts. This Implicit Zero 
hardware feature has no performance cost for ordinary sized stack frames 
(member-dependent but typically anything up to 4KB), and is 
substantially faster than an initialization loop for larger frames. The 
code generator elides explicit zero initialization of frame locals, 
improving both space and time performance for this common action.

Besides precluding rubble-browsing and improving performance, 
implicit-zero also provides consistent behavior for incorrect programs 
that that read uninitialized frame data. The value read will be 
consistently zero on a Mill, whereas on other CPUs it will be whatever 
the last call or interrupt happened to have left at the address. I'm 
sure many here have had the joy of tracing such bugs :-(

So much for background. The team discussion revolves around what our 
compiler should do given the presence of implicit zero initialization. 
We are using the clang/llvm toolset, but the same issues arise with gcc. 
Reading uninitialized data is unequivocally "undefined behavior" in the 
languages, and the compilers may assume that it doesn't happen and 
optimize accordingly. For example, if the program loads through a 
pointer P and there is another pointer Q that is known to point to a 
value known to be as-yet uninitialized then the compiler can infer that 
the two pointers do not alias and P!=Q, because if they did alias then 
the load through P would be undefined. From that P!=Q knowledge the 
compiler may draw further inferences rather remote from the actual load. 
If if fact P==Q then not only is the result of the load bogus (although 
possibly unused by the program) but the inferences may lead to nasal 
demons elsewhere in the program.

One portion of our team advocates responding to this by having the 
compiler front end insert explicit zero-init for every variable in a new 
frame into the IR, even though those stores are not in fact present in 
the source. If the source does its own explicit initialization of some 
variable then dead-code elision will remove the injected zero-store; if 
the program erroneously omits an explicit initialization then the 
injected zero-inits will survive, and will appear to the optimizer to be 
legitimately from the source. As a result, everything will appear to 
have been initialized, the program will appear to have no 
initialization-undefined behavior, the optimizer cannot deduce P!=Q, and 
that particular set of nasal demons are held at bay. Any of the injected 
zero-stores that survive to the optimized output will be removed by our 
back end as redundant with the hardware Implicit Zero.

The program is still buggy of course. It may get compiler warnings if 
the compiler can deduce use of an uninitialized before the 
pseudo-initializations are injected. On a different CPU it will fail 
valgrind. However by preventing deductions the problems will not 
propagate to remote parts of the program and some of the team feel this 
is a desirable outcome.

That's one view. There's a strongly-held second view of this though. 
Here is a representative internal posting of this second view:

"If you use uninitialized stack variables in clang you get compiler 
warnings. If you ignore the warnings, you get implicit zero anyway.

Our compiler already does a good job of eliding explicit zero 
initializations when they reach us.

If you can spot an explicit zero-initialization that I do not elide, 
please raise a bug.

So we should encourage programmers to explicitly zero. We should 
implement memset and bzero to unback whole-pages etc. The outcome is 
that whilst programmers explicitly zero, in most cases this is cheap or 
free on the Mill.

The idea that we should make it so clang explicitly zero-initializes 
things is perverse. This runs contrary to everything clang and the 
future C++ GSL initiative stand for. Everyone wants tooling to get more 
hygienic, nor more forgiving."

Please weigh in on this discussion, in favor of either view or with your 
own take on the situation.

[toc] | [next] | [standalone]


#33468

FromNoob <root@127.0.0.1>
Date2016-02-04 09:07 +0100
Message-ID<n8v0n7$117$1@dont-email.me>
In reply to#33460
On 03/02/2016 23:59, Ivan Godard wrote:

> This note is about an ongoing and as yet unsettled internal discussion 
> about how the Mill should view the program/programmer/compiler/language 
> relationship as it impacts the architecture and toolset design.
> 
> Anyone reading here is aware of the "nasal demon" controversy: that 
> compilers may assume that formally undefined behavior does not appear in 
> a program, and in consequence deduce conclusions and emit code (AKA 
> nasal demons) that are surprising to the programmer. The Mill has chosen 
> to be acutely security-conscious as part of its market positioning, and 
> some of the "surprising" demons have led to security violations.

Ivan,

I haven't heard the term "nasal demons" outside of C and its insane
sibling. Thus, you should consider posting (or cross-posting) to the
relevant newsgroups (comp.lang.c / comp.lang.c++)

Several people here are very good at hand-waving about the standards,
but, sometimes, one actually needs C&V. You might also consider
comp.std.c if it ever comes down to interpretation of the standard.
(Low traffic newsgroup)

Regards.

[toc] | [prev] | [next] | [standalone]


#33471

Fromrpw3@rpw3.org (Rob Warnock)
Date2016-02-04 10:20 +0000
Message-ID<56b325fb$0$32849$742ec2ed@news.sonic.net>
In reply to#33468
Noob <root@127.0.0.1> wrote:
+---------------
| I haven't heard the term "nasal demons" outside of C
| and its insane sibling.
+---------------

FWIW, it's also widely used in the Lisp community, e.g.:

1.  http://www.cliki.net/nasal%20demons
    Nasal Demons
    An euphemism for undefined consequenses. See Jargon File entry.
    Manifestations in comp.lang.lisp: ...[elided]...

2.  https://common-lisp.net/project/ecl/quarterly/volume2.html#orgheadline12
    ...[Section 5.2]...
    5.2 Case on LET / FLET / LABELS (aka Nasal Demons Reborn)

3.  http://stackoverflow.com/questions/31170665/can-common-lisp-type-annotations-result-in-unsound-behavior
    ...[First answer]...
    In SBCL if you smell nasal demons you can restart the image and ...

4.  http://sourceforge.net/p/sbcl/mailman/message/11217173/
    [Sbcl-devel] Deadlines, branches, locks
    ...
    * Almost builds McCLIM. Some of the problems are nasal demons
      revealed by package locks...

And so on...


-Rob

-----
Rob Warnock		<rpw3@rpw3.org>
627 26th Avenue		<http://rpw3.org/>
San Mateo, CA 94403

[toc] | [prev] | [next] | [standalone]


#33477

FromNoob <root@127.0.0.1>
Date2016-02-04 13:46 +0100
Message-ID<n8vh23$rc5$1@dont-email.me>
In reply to#33471
On 04/02/2016 11:20, Rob Warnock wrote:

> Noob wrote:
> +---------------
> | I haven't heard the term "nasal demons" outside of C
> | and its insane sibling.
> +---------------
> 
> FWIW, it's also widely used in the Lisp community, e.g.:

Interesting. Though Lisp predates C, it would seem that the
expression "nasal demons" (not the underlying concept of
undefined behavior) originated from C, and not even that
long ago:

http://www.catb.org/jargon/html/N/nasal-demons.html

Regards.

[toc] | [prev] | [next] | [standalone]


#33480

Fromrpw3@rpw3.org (Rob Warnock)
Date2016-02-04 14:06 +0000
Message-ID<56b35af7$0$32899$742ec2ed@news.sonic.net>
In reply to#33477
Noob  <root@127.0.0.1> wrote:
+---------------
| Rob Warnock wrote:
| > FWIW, it's also widely used in the Lisp community, e.g.:
| 
| Interesting. Though Lisp predates C, it would seem that the
| expression "nasal demons" (not the underlying concept of
| undefined behavior) originated from C, and not even that
| long ago:
| 
| http://www.catb.org/jargon/html/N/nasal-demons.html
+---------------

Hey, that's dated 1992, which is almost a quarter century ago!
That's almost *forever* in Internet time.  ;-}

On the Lisp side, I see mentions in a Scheme forum back
in 2001, so that's at least 15 years. And I have archives
from "comp.lang.lisp" that mention them in 2005.

But even before that, there were other phrases used in
the Lisp community for the consequences of undefined
behavior, including "launch missiles", "start WW3",
or "trigger global thermonuclear war".  ;-}  ;-}


-Rob

-----
Rob Warnock		<rpw3@rpw3.org>
627 26th Avenue		<http://rpw3.org/>
San Mateo, CA 94403

[toc] | [prev] | [next] | [standalone]


#33472

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 10:30 +0000
Message-ID<n8v987$uq1$1@dont-email.me>
In reply to#33468
In article <n8v0n7$117$1@dont-email.me>, Noob  <root@127.0.0.1> wrote:
>
>I haven't heard the term "nasal demons" outside of C and its insane
>sibling. Thus, you should consider posting (or cross-posting) to the
>relevant newsgroups (comp.lang.c / comp.lang.c++)

Well, I have.  It is merely the modern equivalent of "declaring World
War III"; God alone know why it took over or where it came from.

>Several people here are very good at hand-waving about the standards,
>but, sometimes, one actually needs C&V. You might also consider
>comp.std.c if it ever comes down to interpretation of the standard.
>(Low traffic newsgroup)

If you want chapter and verse, I have various documents written in
the past that give them, typically of a few hundred lines long.
No, I am not going to post them.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33478

FromNoob <root@127.0.0.1>
Date2016-02-04 13:55 +0100
Message-ID<n8vhi3$squ$1@dont-email.me>
In reply to#33472
On 04/02/2016 11:30, Nick Maclaren wrote:

> Noob wrote:
>
>> I haven't heard the term "nasal demons" outside of C and its insane
>> sibling. Thus, you should consider posting (or cross-posting) to the
>> relevant newsgroups (comp.lang.c / comp.lang.c++)
> 
> Well, I have.

I didn't expect anything less.

> It is merely the modern equivalent of "declaring World
> War III"; God alone know why it took over or where it came from.

AFAICT, the locution originated in a C newsgroup.

>> Several people here are very good at hand-waving about the standards,
>> but, sometimes, one actually needs C&V. You might also consider
>> comp.std.c if it ever comes down to interpretation of the standard.
>> (Low traffic newsgroup)
> 
> If you want chapter and verse, I have various documents written in
> the past that give them, typically of a few hundred lines long.
> No, I am not going to post them.

These documents... you've posted them to comp.arch in the past?
(Because if they're not accessible, they're not very useful.)

Regards.

[toc] | [prev] | [next] | [standalone]


#33484

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 14:52 +0000
Message-ID<n8voj0$p9r$1@dont-email.me>
In reply to#33478
In article <n8vhi3$squ$1@dont-email.me>, Noob  <root@127.0.0.1> wrote:
>
>>> I haven't heard the term "nasal demons" outside of C and its insane
>>> sibling. Thus, you should consider posting (or cross-posting) to the
>>> relevant newsgroups (comp.lang.c / comp.lang.c++)
>> 
>> Well, I have.
>
>I didn't expect anything less.
>
>> It is merely the modern equivalent of "declaring World
>> War III"; God alone know why it took over or where it came from.
>
>AFAICT, the locution originated in a C newsgroup.

I doubt it, though it probably originated in a C community.

>>> Several people here are very good at hand-waving about the standards,
>>> but, sometimes, one actually needs C&V. You might also consider
>>> comp.std.c if it ever comes down to interpretation of the standard.
>>> (Low traffic newsgroup)
>> 
>> If you want chapter and verse, I have various documents written in
>> the past that give them, typically of a few hundred lines long.
>> No, I am not going to post them.
>
>These documents... you've posted them to comp.arch in the past?
>(Because if they're not accessible, they're not very useful.)

They are.  WG14 and WG21 documents and mailing list archives.  Usenet
is not the primary source for such things.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33486

FromNoob <root@127.0.0.1>
Date2016-02-04 16:28 +0100
Message-ID<n8vqh5$1ta$1@dont-email.me>
In reply to#33484
On 04/02/2016 15:52, Nick Maclaren wrote:

> Noob wrote:
>
>> These documents... you've posted them to comp.arch in the past?
>> (Because if they're not accessible, they're not very useful.)
> 
> They are.  WG14 and WG21 documents and mailing list archives.  Usenet
> is not the primary source for such things.

Is the WG14 ML archive searchable?

I found an INDEX, which is lacking authorship.
http://www.open-std.org/JTC1/SC22/WG14/INDEX

I did find one of your older messages:
http://www.open-std.org/jtc1/sc22/wg14/9350

It doesn't look like Google crawled the entire website.
https://www.google.com/?q=site:open-std.org/jtc1/sc22/wg14+%22maclaren%22

Also apparently you used to post to comp.std.c
Do you still do it on occasion?

Regards.

[toc] | [prev] | [next] | [standalone]


#33487

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 16:38 +0000
Message-ID<n8vuq4$jqb$1@dont-email.me>
In reply to#33486
In article <n8vqh5$1ta$1@dont-email.me>, Noob  <root@127.0.0.1> wrote:
>
>Is the WG14 ML archive searchable?

God alone knows.  I gave up on it after C99 because it was bad for
my blood pressure and not achieving anything useful; essentially
all of the UK people did, though I cannot say what their reasons
were.  However, the National Body vote of No, Nohow, No way had
only two in dissent at the relevant meeting, and one of those was
on the grounds of maintaining good relations.

>Also apparently you used to post to comp.std.c
>Do you still do it on occasion?

No.  I am still active in WG5, and slightly so in WG21, but rarely
look at the language newsgroups.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33473

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 10:40 +0000
Message-ID<n8v9qg$11n$1@dont-email.me>
In reply to#33460
In article <n8u0jv$4tl$1@dont-email.me>,
Ivan Godard  <ivan@millcomputing.com> wrote:
>
>That's one view. There's a strongly-held second view of this though. 
>Here is a representative internal posting of this second view:
>
>"If you use uninitialized stack variables in clang you get compiler 
>warnings. If you ignore the warnings, you get implicit zero anyway.
...
The idea that we should make it so clang explicitly zero-initializes 
things is perverse. This runs contrary to everything clang and the 
future C++ GSL initiative stand for. Everyone wants tooling to get more 
hygienic, nor more forgiving."

As you know, what I would really like is automatic initialisation
to a trap value so that, if you ignore the warnings, you get a
run-time error.  That would enable keeping the optimisations, but
would guarantee that they can't cause undetected wrong answers.

Incidentally, BCPL automatic declarations were originally of the
form 'LET A = 123, B = 456, ...' and initialisation was syntactically
mandatory.  'LET A = ?' came later.  End of history lesson :-)


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33474

FromIvan Godard <ivan@millcomputing.com>
Date2016-02-04 02:58 -0800
Message-ID<n8vang$38k$1@dont-email.me>
In reply to#33473
On 2/4/2016 2:40 AM, Nick Maclaren wrote:


> As you know, what I would really like is automatic initialisation
> to a trap value so that, if you ignore the warnings, you get a
> run-time error.  That would enable keeping the optimisations, but
> would guarantee that they can't cause undetected wrong answers.

Unfortunately the Implicit Zero hardware can't do that. We do have 
trapping values that use metadata to mark them as NaR (Not a Result), 
but the metadata only exists on the belt and in scratchpad. Not only 
would it be too expensive to put the metadata in caches or memory, but 
the semantics are unclear when it is possible to use byte-aligned access 
to address into the middle of an operand. The belt/scratch are not byte 
addressable; they hold complete operands as such, and those are 
unambiguously valid as a whole - or not.

[toc] | [prev] | [next] | [standalone]


#33475

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 12:20 +0000
Message-ID<n8vfn0$mjg$1@dont-email.me>
In reply to#33474
In article <n8vang$38k$1@dont-email.me>,
Ivan Godard  <ivan@millcomputing.com> wrote:
>
>> As you know, what I would really like is automatic initialisation
>> to a trap value so that, if you ignore the warnings, you get a
>> run-time error.  That would enable keeping the optimisations, but
>> would guarantee that they can't cause undetected wrong answers.
>
>Unfortunately the Implicit Zero hardware can't do that. We do have 
>trapping values that use metadata to mark them as NaR (Not a Result), 
>but the metadata only exists on the belt and in scratchpad. Not only 
>would it be too expensive to put the metadata in caches or memory, but 
>the semantics are unclear when it is possible to use byte-aligned access 
>to address into the middle of an operand. The belt/scratch are not byte 
>addressable; they hold complete operands as such, and those are 
>unambiguously valid as a whole - or not.

And that applies to pretty well ANY way of tagging memory as invalid,
unfortunately.  At one point, I tried to get some clarification on
the following and got the usual "yes, obviously", "no, obviously"
and "it's obvious":

    double x;
    if (*(unsigned char *)&x == *(unsigned char *)&x) ...

Ignoring the expense issue, it would be feasible to do some trapping
in almost all languages, but some changes would be needed to C to
to enable it.  Possibly only by clarifying that the unsigned char
exemption does not apply to undefined data.

I don't like automatic initialisation to zero, because I have seen
just too much code rely on it, which then breaks when it is moved to
a system where it is not so.  Automatic initialisation to a random
value is far better, from the portability and correctness point of
view.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33490

FromIvan Godard <ivan@millcomputing.com>
Date2016-02-04 09:34 -0800
Message-ID<n901tt$9d$1@dont-email.me>
In reply to#33475
On 2/4/2016 4:20 AM, Nick Maclaren wrote:

> I don't like automatic initialisation to zero, because I have seen
> just too much code rely on it, which then breaks when it is moved to
> a system where it is not so.  Automatic initialisation to a random
> value is far better, from the portability and correctness point of
> view.

There's a business (not technical) argument that says that consequence 
is a feature, not a bug.

[toc] | [prev] | [next] | [standalone]


#33494

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 18:25 +0000
Message-ID<n9052m$erm$1@dont-email.me>
In reply to#33490
In article <n901tt$9d$1@dont-email.me>,
Ivan Godard  <ivan@millcomputing.com> wrote:
>
>> I don't like automatic initialisation to zero, because I have seen
>> just too much code rely on it, which then breaks when it is moved to
>> a system where it is not so.  Automatic initialisation to a random
>> value is far better, from the portability and correctness point of
>> view.
>
>There's a business (not technical) argument that says that consequence 
>is a feature, not a bug.

Oh, yes - I thought of that when posting.  But it is a flawed argument,
as IBM and many other vendors discovered, way back when.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33476

FromJan Coombs <jenfhaomndgfwutc@murmic.plus.com>
Date2016-02-04 12:46 +0000
Message-ID<20160204124617.15ca93d8@t500>
In reply to#33474
On Thu, 4 Feb 2016 02:58:38 -0800
Ivan Godard <ivan@millcomputing.com> wrote:

> On 2/4/2016 2:40 AM, Nick Maclaren wrote:
> 
> 
> > As you know, what I would really like is automatic
> > initialisation to a trap value so that, if you ignore the
> > warnings, you get a run-time error.  That would enable
> > keeping the optimisations, but would guarantee that they
> > can't cause undetected wrong answers.
> 
> Unfortunately the Implicit Zero hardware can't do that. We do
> have trapping values that use metadata to mark them as NaR
> (Not a Result), but the metadata only exists on the belt and
> in scratchpad. Not only would it be too expensive to put the
> metadata in caches or memory, but the semantics are unclear
> when it is possible to use byte-aligned access to address into
> the middle of an operand. The belt/scratch are not byte
> addressable; they hold complete operands as such, and those
> are unambiguously valid as a whole - or not.

The Transputer had a reserved data value which caused a system
trap. 

If the belt has a RAM read path equal or greater than the system
word size, and narrower read data are selected near the belt,
then the invalid/trap status could be transferred to the belt
without altering any of the required data bits. 

Jan Coombs

[toc] | [prev] | [next] | [standalone]


#33482

FromMitchAlsup <MitchAlsup@aol.com>
Date2016-02-04 06:43 -0800
Message-ID<f000afef-b26d-4ac1-8294-11e2373cb790@googlegroups.com>
In reply to#33474
On Thursday, February 4, 2016 at 4:58:38 AM UTC-6, Ivan Godard wrote:
> On 2/4/2016 2:40 AM, Nick Maclaren wrote:
> 
> 
> > As you know, what I would really like is automatic initialisation
> > to a trap value so that, if you ignore the warnings, you get a
> > run-time error.  That would enable keeping the optimisations, but
> > would guarantee that they can't cause undetected wrong answers.
> 
> Unfortunately the Implicit Zero hardware can't do that. We do have 
> trapping values that use metadata to mark them as NaR (Not a Result), 
> but the metadata only exists on the belt and in scratchpad. Not only 
> would it be too expensive to put the metadata in caches or memory, but 
> the semantics are unclear when it is possible to use byte-aligned access 
> to address into the middle of an operand. 

What you want is basically a way of returning "bad ECC" in response to
reading any uninitialized byte in memory. This gets nasty if someone 
initializes 3 bytes and then reads a word (4 bytes) containing 3 good
units of data and one bad unit of data.

That is, you don't want the data to contains a pattern that says uninitialized,
you want the uninitialized unit of memory to be able to contain any bit
pattern and still retain the notion of uninitialized.

[toc] | [prev] | [next] | [standalone]


#33483

Fromnmm@wheeler.UUCP (Nick Maclaren)
Date2016-02-04 14:49 +0000
Message-ID<n8voec$ond$1@dont-email.me>
In reply to#33482
In article <f000afef-b26d-4ac1-8294-11e2373cb790@googlegroups.com>,
MitchAlsup  <MitchAlsup@aol.com> wrote:
>
>What you want is basically a way of returning "bad ECC" in response to
>reading any uninitialized byte in memory. This gets nasty if someone 
>initializes 3 bytes and then reads a word (4 bytes) containing 3 good
>units of data and one bad unit of data.

That's not a problem - that's undefined, so trap.  A much worse one
involves padding in structures (in most languages), C unsigned char
exemptions, and similar horrors where locations can be invalid for
one use but not for another.


Regards,
Nick Maclaren.

[toc] | [prev] | [next] | [standalone]


#33479

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-02-04 13:18 +0000
Message-ID<2016Feb4.141817@mips.complang.tuwien.ac.at>
In reply to#33460
Ivan Godard <ivan@millcomputing.com> writes:
>So much for background. The team discussion revolves around what our 
>compiler should do given the presence of implicit zero initialization. 
>We are using the clang/llvm toolset, but the same issues arise with gcc. 

A bad tree cannot bear good fruit (Matthew 7:18).  Either you want
nasal demons or you don't.  In the latter case, clang/llvm and gcc are
bad trees; they are big programs, and the nasal demon assumption is
spread wide and deep throughout them, and is getting spread wider and
deeper with every release by the current maintainers.  My guess is
that it's easier to write a new compiler or at least front end than to
sanitize these compilers from nasal demons, especially if you consider
maintenance.

Given that you chose to work with clang/LLVM, trying to work around
nasal demons by trying to insert additional IR code looks not very
promising as a general approach to me, but I guess your people have
thought about this much more than I have, so I may be wrong.

If you are not looking for getting rid of nasal demons in general, but
only of those related to the use of uninitialized variables, I wonder
about the cost/benefit ratio.  Even programmers who do not expect
nasal demons from compilers tend to avoid using uninitialized
variables, because the values of these variables tend to change on
maintenance, even if not in different executions; and they have been
helped in avoiding that by compiler warnings even in the days when
nasal demons were just figments from a C-hater's dream.

- anton
-- 
M. Anton Ertl                    Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html

[toc] | [prev] | [next] | [standalone]


#33493

Fromtimcaffrey@aol.com
Date2016-02-04 10:05 -0800
Message-ID<dc51ed4a-1877-4f21-9088-9127139ccbd7@googlegroups.com>
In reply to#33460
On Wednesday, February 3, 2016 at 5:59:58 PM UTC-5, Ivan Godard wrote:
[snip]
> Please weigh in on this discussion, in favor of either view or with your 
> own take on the situation.

If I understand this correctly, this would be a fairly late injection
into the IR stream, so it should not interfere with the compiler
giving warnings that what you are using an undefined variable.
(for extra points, make it an error).

Since the local variables are implicitly zero'd, I would say
this is an implementation artifact, and the compiler should be aware
of it to generate correct code for the platform.  C (and C++) are 
inherently low level languages, and the underlying hardware implementation
is always visible to a degree.

               - Tim

[toc] | [prev] | [standalone]


Back to top | Article view | comp.arch


csiph-web