OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Jan 19, 2019 3:33 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Volatiles are often miscompiled
PostPosted: Sun Apr 20, 2014 7:00 pm 
Offline
Member
Member

Joined: Tue Apr 13, 2010 8:00 pm
Posts: 285
Thought you guys might be interested in this: http://www.cs.utah.edu/~regehr/papers/e ... eprint.pdf.


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Sun Apr 20, 2014 11:34 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1067
Location: Tartu, Estonia
A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Sun Apr 20, 2014 11:38 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 920
XenOS wrote:
A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.


Would you care to elaborate on how exactly it's not up to date?


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 12:25 am 
Offline
Member
Member

Joined: Mon Jan 03, 2011 6:58 pm
Posts: 283
alexfru wrote:
XenOS wrote:
...


Would you care to elaborate on how exactly it's not up to date?


Check the versions of the compilers used in the paper vs. current versions of the same compilers.

XenOS is right that it's something we need to look out for in specific circumstances (code not doing what we expect with volatile variables) but this is not likely to cause many bugs after *6* years of updates to compilers.

- Monk


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 12:53 am 
Offline
Member
Member

Joined: Tue Apr 13, 2010 8:00 pm
Posts: 285
XenOS wrote:
A paper from 2008 is not quite up to date with current compilers and standards, but still interesting to read and certainly good to know. One should keep this in mind when searching for bugs with volatile variables, and double check the compiler output in that case.

Volatile wasn't exactly new in '08. It was in the original K&R C released in 1978. If the bugs hadn't been fixed in the 30 years previous, they likely weren't fixed in the 6 years following. That is, unless this paper brought the bugs to compiler devs' attention. But even then, I would guess the reason they lasted 30 years probably had something to do with the difficulty in fixing them, which would increase the likelihood they still aren't fixed.

You have to admit, it's pretty astounding that after 30 years of development (of the technology/methods, not the compilers themselves), not a single compiler got it right.


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 1:05 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 920
tjmonk15 wrote:
alexfru wrote:
XenOS wrote:
...


Would you care to elaborate on how exactly it's not up to date?


Check the versions of the compilers used in the paper vs. current versions of the same compilers.


Compiler versions aren't of much relevance, they aren't definitive. The main question is about what has changed in the language standard(s) and which version of the standard which compiler supports. Since 2008 there's been only one standard update (C++03 -> C++11 and C99 -> C11). It would be nice to hear not just that the paper is somewhat outdated, but how, it shouldn't be a huge difference (a paragraph perhaps, maybe a little more?), right?


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 1:25 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9269
Location: An der schönen blauen Donau, watching muppets
Quote:
Compiler versions aren't of much relevance
Then you didn't properly read what the paper said itself:
Quote:
because, as of this writing, no release incorporates fixes to all of the bugs we reported. (...) Our experiment is ongoing and we expect that within the
foreseeable future, LLVM - GCC will be effectively free of volatile and functional bugs for the programs emitted by randprog.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 3:03 am 
Offline
Member
Member
User avatar

Joined: Fri Jul 03, 2009 6:21 am
Posts: 359
alexfru wrote:
Compiler versions aren't of much relevance, they aren't definitive.

Oh but they are. Upgrading is a cost/benefit question for many non-hobby projects.

alexfru wrote:
The main question is about what has changed in the language standard(s) and which version of the standard which compiler supports. Since 2008 there's been only one standard update (C++03 -> C++11 and C99 -> C11).

Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.
As someone who has implemented an ISO standard compliant programming language, I'll say that standards are created for many reasons, many of which are non-technical.

_________________
Every universe of discourse has its logical structure --- S. K. Langer.


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Mon Apr 21, 2014 10:06 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1067
Location: Tartu, Estonia
tjmonk15 wrote:
alexfru wrote:
Would you care to elaborate on how exactly it's not up to date?

Check the versions of the compilers used in the paper vs. current versions of the same compilers.

Exactly. Those compiler versions are really outdated. And even if these bugs existed for 30 years, they were discovered, pointed out in this article and reported:
Combuster wrote:
Quote:
Compiler versions aren't of much relevance
Then you didn't properly read what the paper said itself:
Quote:
because, as of this writing, no release incorporates fixes to all of the bugs we reported. (...) Our experiment is ongoing and we expect that within the
foreseeable future, LLVM - GCC will be effectively free of volatile and functional bugs for the programs emitted by randprog.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Thu May 29, 2014 12:45 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3864
Location: Eindhoven
bwat wrote:
Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.


Wow.

ANSI is just the American standards institute. The International Standards Organisation (ISO) produces documents called ISO9899 and ISO14882, which describe C and C++ in their international variants which have been the norm since 1989. That's where C99 and C11 come from - C99 is short for ISO9899:1999 and C11 is short for ISO9899:2011.

That's a pretty ignorant stance to have. Try to at least think outside of the US-centered box that you currently live in.


Top
 Profile  
 
 Post subject: Re: Volatiles are often miscompiled
PostPosted: Thu May 29, 2014 6:47 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Candy wrote:
bwat wrote:
Standards are fairly meaningless unless they're adopted. I use ANSI C so C99 and C11 have absolutely no meaning to me and I'm not alone.


ANSI is just the American standards institute. The International Standards Organisation (ISO) produces documents called ISO9899 and ISO14882, which describe C and C++ in their international variants which have been the norm since 1989. That's where C99 and C11 come from - C99 is short for ISO9899:1999 and C11 is short for ISO9899:2011.

That's a pretty ignorant stance to have. Try to at least think outside of the US-centered box that you currently live in.


It has nothing to do with geography or standard bodies (e.g. ANSI vs. ISO); and everything to do with history. Basically; bwat prefers "old" and doesn't like "new" (and doesn't care about which standard body was responsible for "old").

Note that I'm mostly the same. I mostly learnt C from "The C Programming Language (second edition)", and haven't really bothered learning anything that was added to C since (excluding my flagrant abuse of "//" for single line comments).

Maybe one day they're release a third edition of this book, and programmers will start learning C11 (and ignore all versions of C created after that).. ;)


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group