* 4.0D/4.0E DEC C optimization bug
@ 1999-04-10 4:00 Joerg Czeranski
1999-04-12 4:00 ` Bernhard Reiter
1999-04-13 4:00 ` Jeff Sullivan
0 siblings, 2 replies; 5+ messages in thread
From: Joerg Czeranski @ 1999-04-10 4:00 UTC (permalink / raw)
Hi,
DEC C V5.6-071 on Digital UNIX V4.0 (Rev. 878),
DEC C V5.7-566 (cc.alt) on Digital UNIX V4.0 (Rev. 878), and
DEC C V5.8-009 on Digital UNIX V4.0 (Rev. 1091)
(I didn't check any others, but AFAIR the same source worked with
the Dec Unix 4.0A compiler)
exhibit a problem compiling sigsetjmp with optimization:
If a local non-volatile automatic variable is written before
the sigsetjmp and read in the "true" branch of "if (sigsetjmp(...))"
but not used elsewhere, the compiler might decide sharing
its location with a different local variable between sigsetjmp
and siglongjmp.
The documentation, the C9X draft, and the Single Unix Spec. say
that such a variable may only have an indeterminant value if it's
written after a setjmp - referring to setjmp/longjmp.
Am I mistaken in assuming the same should apply to sigsetjmp/siglongjmp
or is this a bug?
I found this problem when I compiled the Objective Caml compiler, and
isolated it.
I'll post a source listing that demonstrates it.
joerch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 4.0D/4.0E DEC C optimization bug
1999-04-10 4:00 4.0D/4.0E DEC C optimization bug Joerg Czeranski
@ 1999-04-12 4:00 ` Bernhard Reiter
1999-04-13 4:00 ` Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
1 sibling, 1 reply; 5+ messages in thread
From: Bernhard Reiter @ 1999-04-12 4:00 UTC (permalink / raw)
On Sat, 10 Apr 1999 23:42:03 +0200 (MET DST), Joerg Czeranski <jc@joerch.org> wrote:
>DEC C V5.6-071 on Digital UNIX V4.0 (Rev. 878),
>DEC C V5.7-566 (cc.alt) on Digital UNIX V4.0 (Rev. 878), and
>DEC C V5.8-009 on Digital UNIX V4.0 (Rev. 1091)
>(I didn't check any others, but AFAIR the same source worked with
>the Dec Unix 4.0A compiler)
>exhibit a problem compiling sigsetjmp with optimization:
I also have send a DEC cc compiler question to one of the
comp.unix.osf. newgroups. I never got any responses.
I therefore guess that this is not the right place to report this
bug. Hmm I wonder where that would be.
Bernhard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 4.0D/4.0E DEC C optimization bug
1999-04-12 4:00 ` Bernhard Reiter
@ 1999-04-13 4:00 ` Jeff Sullivan
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Sullivan @ 1999-04-13 4:00 UTC (permalink / raw)
Bernhard Reiter wrote:
>
> I also have send a DEC cc compiler question to one of the
> comp.unix.osf. newgroups. I never got any responses.
>
> I therefore guess that this is not the right place to report this
> bug. Hmm I wonder where that would be.
> Bernhard
Bernhard and Joerg,
comp.unix.osf.osf1 a good place to post these questions. We try
to monitor these newsgroups as best we can.
We do have an answer to Joerg's question and will post it
shortly.
We have also addressed Bernhard's suggestion originally posted
in comp.unix.osf.misc in a future Compaq C compiler. I will
also post that answer separately.
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 4.0D/4.0E DEC C optimization bug
1999-04-10 4:00 4.0D/4.0E DEC C optimization bug Joerg Czeranski
1999-04-12 4:00 ` Bernhard Reiter
@ 1999-04-13 4:00 ` Jeff Sullivan
1999-04-15 4:00 ` Joerg Czeranski
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Sullivan @ 1999-04-13 4:00 UTC (permalink / raw)
The following answer comes from one of our ANSI experts.
<quote>
My take on this is that it's a bug in that the compiler does not know
that sigsetjmp behaves like setjmp. The Single UNIX Spec has the same
words about sigsetjmp and the values of non-volatile locals as the C89
and C9X specs have for setjmp and non-volatile locals. If this
example is coded with setjmp/longjmp instead of the sig-prefixed
versions, then we generate different code that prevents the lifetime
splitting.
I believe the reason we get the right answer for setjmp is that the
compiler always recognizes it as an intrinsic and does the following:
1. We mark the tuple representing the call to setjmp as having abnormal
control flow.
2. We store the result of the call in a temp.
2a. We do some exotic stuff I don't understand to deal with the
possibility of structured exception handling.
3. We generate a volatile label, noting that the label can be reached
by a non-local goto.
4. We generate a fetch of the temp used to hold the result of the
setjmp call.
The user's code doesn't work as expected using sigsetjmp because we
don't recognize it as an intrinsic and do all this fancy stuff.
Workarounds would be to use setjmp instead of sigsetjmp, make the
variables volatile, or compile -O0 (split lifetime analysis is
documented as coming on at -O1).
To fix the bug, the compiler would have to recognize sigsetjmp as well
as setjmp and treat it similarly, which may be harder than it sounds
since sigsetjmp has a different signature (two parameters instead of
one), and the hairy code that deals with setjmp appears to have the
routine's signature (and name?) sort of "wired in". Since sigsetjmp
is not in the C standard, but is declared in <setjmp.h>, I think the
mechanism for making it intrinsic would require an explicit
#pragma intrinsic(sigsetjmp)
</quote>
We will look into resolving the above mentioned problem with
sigsetjmp in future versions of Compaq C.
Let us know if this helps.
Thanks,
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 4.0D/4.0E DEC C optimization bug
1999-04-13 4:00 ` Jeff Sullivan
@ 1999-04-15 4:00 ` Joerg Czeranski
0 siblings, 0 replies; 5+ messages in thread
From: Joerg Czeranski @ 1999-04-15 4:00 UTC (permalink / raw)
Jeff Sullivan wrote in <3713880D.ECF3B246@zk3.dec.com>:
> The following answer comes from one of our ANSI experts.
[detailed analysis snipped...]
> Workarounds would be to use setjmp instead of sigsetjmp, make the
> variables volatile, or compile -O0 (split lifetime analysis is
> documented as coming on at -O1).
[what the compiler would have to do to prevent the problem...]
> We will look into resolving the above mentioned problem with
> sigsetjmp in future versions of Compaq C.
>
> Let us know if this helps.
>
> Thanks,
> -Jeff
I noticed that I couldn't reproduce the problem with setjmp,
and that making it volatile makes it go away, too.
In this case volatile doesn't hurt at all, because the variable
is almost never used. I sent such a patch to the authors,
and I think it's a good idea to keep it, other compilers might
suffer from the same problem.
Actually some version of gcc is said to have a similar symptom,
SEGV in the same program, but I don't know if that relates to
sigsetjmp, because I couldn't reproduce it.)
I'm very pleased by your fast and competent answer.
joerch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-04-15 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-04-10 4:00 4.0D/4.0E DEC C optimization bug Joerg Czeranski
1999-04-12 4:00 ` Bernhard Reiter
1999-04-13 4:00 ` Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
1999-04-15 4:00 ` Joerg Czeranski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox