Cyclone (programming language): Difference between revisions

Content deleted Content added
Clean up/copyedit
Line 28:
The '''Cyclone''' [[programming language]] is intended to be a safe dialect of the [[C (programming language)|C language]]. Cyclone is designed to avoid [[buffer overflow]]s and other vulnerabilities that are possible in C programs, without losing the power and convenience of C as a tool for [[system programming]].
 
Cyclone development was started as a joint project of [[AT&T Labs]] Research and [[Greg Morrisett]]'s group at [[Cornell University]] in 2001. Version 1.0 was released on May 8, 2006.<ref>{{cite web |title=Cyclone |url=http://www.cs.cornell.edu/Projects/cyclone/ |website=[[Cornell University]]}}</ref>
 
==Language features==
Line 35:
* [[Pointer arithmetic]] is limited
* Pointers must be initialized before use (this is enforced by [[definite assignment analysis]])
* [[Dangling pointer]]s are prevented through region analysis and limits on [[Malloc|<code>[[free()]]</code>]]
* Only "safe" casts and unions are allowed
* [[Control flow|<code>goto</code>]] into scopes is disallowed
* [[Control flow|<code>switch</code>]] labels in different scopes are disallowed
* Pointer-returning functions must execute <code>return</code>
* [[Setjmp/longjmp.h|<code>setjmp</code>]] and [[Setjmp/longjmp|<code>longjmp</code>]] are not supported
 
To maintain the tool set that C programmers are used to, Cyclone provides the following extensions:
Line 55:
For a better high-level introduction to Cyclone, the reasoning behind Cyclone and the source of these lists, see [http://www.cs.umd.edu/projects/cyclone/papers/cyclone-safety.pdf this paper].
 
Cyclone looks, in general, much like [[C (programming language)|C]], but it should be viewed as a C-like language.
 
===Pointer types===
Line 109:
}
</syntaxhighlight>
FunctionThe function <code>itoa</code> allocates an array of chars <code>buf</code> on the stack and returns a pointer to the start of <code>buf</code>. However, the memory used on the stack for <code>buf</code> is deallocated when the function returns, so the returned value cannot be used safely outside of the function. While [[GNU Compiler Collection|gcc]] and other compilers will warn about such code, the following will typically compile without warnings:
<syntaxhighlight lang="C">
char *itoa(int i)
Line 119:
}
</syntaxhighlight>
[[GNU Compiler Collection|gcc]] can produce warnings for such code as a side-effect of option {{code|-O2}} or {{code|-O3}}, but there are no guarantees that all such errors will be detected.
Cyclone does regional analysis of each segment of code, preventing dangling pointers, such as the one returned from this version of <code>itoa</code>. All of the local variables in a given scope are considered to be part of the same region, separate from the heap or any other local region. Thus, when analyzing <code>itoa</code>, the Cyclone compiler would see that <code>z</code> is a pointer into the local stack, and would report an error.
 
Line 131:
 
==External links==
* [http://cyclone.thelanguage.org/ Cyclone Homepagehomepage]
* [https://web.archive.org/web/20111227232825/http://www.eecs.harvard.edu/~greg/cyclone/old_cyclone.html Old web site] since official web site is not available.
* [http://cyclone.thelanguage.org/wiki/Download Cyclone - Sourcesource code repositories]
* [http://cyclone.thelanguage.org/wiki/Frequently%20Asked%20Questions Cyclone - FAQ]
* [http://cyclone.thelanguage.org/wiki/Cyclone%20for%20C%20Programmers Cyclone for C programmers]
* [http://cyclone.thelanguage.org/wiki/User%20Manual Cyclone Useruser Manualmanual]
* [http://www.cs.umd.edu/~mwh/papers/cyclone-cuj.pdf Cyclone: a Type-safe Dialect of C] by Dan Grossman, Michael Hicks, Trevor Jim, and Greg Morrisett - published January 2005