473,670 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The C language in the planet Mars

Mankind has now two robots wandering about in the planet Mars. No,
it wasn't Mars that invaded Earth, but Earth that landed in Mars
more than two years ago.

After some initial OS glitches (Chris Torek can comment
on those probably) in the Spirit robot, software has done
smoothly ever since.

All the software is written in C, what is a good decision
but also a bad one, C with its warts and all...

In the last two weeks, a software upgrade was sent from
earth to Mars, and the upgrade is scheduled to be
tested this days. Software upgrades take a lot of time
when they are done with several million kilometers
distance!

The Mars Exploration Rover software (MER) is around
650 000 lines of C. The Ames research center developed a
static tester for the software [2] and in 30 minutes
it discovered...

o Un-initialized variable usage
o Returning the address of a local variable (!!!!)
o Overflow in constant expression.

I wonder what kind of compilers does the VXWorks system
use, but almost all compilers I know of will try to
diagnose this kind of errors...

In a news item published in Space daily [1], Green Hills software
boasted that
< quote >
"Green Hills Software Tools Critical To Mars Rover Missions"

Both the "Opportunit y" rover, launched July 7, and the "Spirit" rover,
launched June 10, are being directed and controlled by software programs
and systems written with the use of Green Hills development tools.

< end quote >

Green Hills doesn't emit a diagnostic for returning the address of
a local variable?
References:
[1]
http://www.marsdaily.com/reports/Gre..._Missions.html
[2]
http://ic.arc.nasa.gov/researchinfus...S/SMC-IT03.pdf
Jul 23 '06 #1
33 3068
In article <44************ *********@news. orange.fr>,
jacob navia <ja***@jacob.re mcomp.frwrote:
>o Returning the address of a local variable (!!!!)
>Green Hills doesn't emit a diagnostic for returning the address of
a local variable?
I don't know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard
Jul 23 '06 #2
Richard Tobin a écrit :
In article <44************ *********@news. orange.fr>,
jacob navia <ja***@jacob.re mcomp.frwrote:

>>o Returning the address of a local variable (!!!!)

>>Green Hills doesn't emit a diagnostic for returning the address of
a local variable?


I don't know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard
Yes, you are right. That would be much more
difficult to find. The other errors are maybe
easier: const overflow can be detected at
compile time.

Jul 23 '06 #3
On 2006-07-23, jacob navia <ja***@jacob.re mcomp.frwrote:
Richard Tobin a écrit :
>In article <44************ *********@news. orange.fr>,
jacob navia <ja***@jacob.re mcomp.frwrote:

>>>o Returning the address of a local variable (!!!!)

>>>Green Hills doesn't emit a diagnostic for returning the address of
a local variable?


I don't know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard

Yes, you are right. That would be much more
difficult to find.
Hmm, maybe it would be feasible to make this a runtime error. With a
typical stack frame layout, the compiler can easily check whether
returned (non-null) pointer values point into the frame, and if that's
the case terminate the process or call a user-defined error handler or
somesuch.

Probably not worth the cost in general, but could come in handy during
development/debugging.

--
Nils R. Weller, Bremen (Germany)
My real email address is ``nils<at>gnuli nux<dot>nl''
.... but I'm not speaking for the Software Libre Foundation!
Jul 23 '06 #4
Richard Tobin wrote:
In article <44************ *********@news. orange.fr>,
jacob navia <ja***@jacob.re mcomp.frwrote:
o Returning the address of a local variable (!!!!)
Green Hills doesn't emit a diagnostic for returning the address of
a local variable?

I don't know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?
I decided to do a little experiment with the programme below.

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;

}

int main() {

return 0 ;
}

The Sun compiler , lint on Solaris and gcc -Wall did not
produce any warnings. But splint gave

o.c:8:12: Stack-allocated storage pointer reachable from return value:
pointer
A stack reference is pointed to by an external reference when the
function
returns. The stack-allocated storage is destroyed after the call,
leaving a
dangling reference. (Use -stackref to inhibit warning)
Spiros Bousbouras

Jul 23 '06 #5
On Sun, 23 Jul 2006 10:44:43 +0200, jacob navia
<ja***@jacob.re mcomp.frwrote:
>Mankind has now two robots wandering about in the planet Mars. No,
it wasn't Mars that invaded Earth, but Earth that landed in Mars
more than two years ago.

After some initial OS glitches (Chris Torek can comment
on those probably) in the Spirit robot, software has done
smoothly ever since.

All the software is written in C, what is a good decision
but also a bad one, C with its warts and all...
Maybe the problem's with the people writing the language as much as it
is with the language itself. French isn't a bad language just because
monkey's can't speak it.

C is good for anal retentive people who catch most of their own
mistakes. It's apparently not good for normal people.

Jul 25 '06 #6
BubbaGump said:

<snip>
>
C is good for anal retentive people who catch most of their own
mistakes.
Are you a qualified psychiatrist, using that term in its medical sense? If
so, please provide evidence to support this.

Or are you just an irksome little jerk who is trying to offend people?
It's apparently not good for normal people.
C is fine for normal people who know how to think. If you don't know how to
think, stay away not just from C, but from programming.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 25 '06 #7
Ham

sp****@gmail.co m wrote:

>
int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;

}

int main() {

return 0 ;
}
PC-LINT produces the following warning for that piece of code:

diy.c 11 Warning 674: Returning address of auto through
variable 'pointer'.

This example is also a sample violation of MISRA C:2004

Jul 25 '06 #8
In article <D9************ ********@bt.com >,
Richard Heathfield <in*****@invali d.invalidwrote:
>BubbaGump said:
>C [...]
>It's apparently not good for normal people.
>C is fine for normal people who know how to think.
There are compelling claims that programmers are not normal people ;-)
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Jul 25 '06 #9
On Tue, 25 Jul 2006, Walter Roberson wrote:
In article <D9************ ********@bt.com >,
Richard Heathfield <in*****@invali d.invalidwrote:
>BubbaGump said:
>>C [...]
>>It's apparently not good for normal people.
>C is fine for normal people who know how to think.

There are compelling claims that programmers are not normal people ;-)
Indeed. A week or so ago, someone on comp.lang.c wrote,
``Neither is anyone. Normality is a myth. (Do the math. How many
people are normal in every respect?)'' (attribution withheld).

Tak-Shing
Jul 25 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

198
18283
by: Michael N. Christoff | last post by:
Java, the software developed by Sun Microsystems in the mid-1990s as a universal operating system for Internet applications, gave NASA a low-cost and easy-to-use option for running Spirit, the robotic rover that rolled onto the planet's surface on Thursday in search of signs of water and life. http://news.com.com/2100-1007_3-5142220.html?tag=nefd_top l8r, Mike N. Christoff
23
2012
by: jacob navia | last post by:
There was a discussion some weeks ago about the C language being "dead", where Mr Tisdale, as far as I know a NASA employee, participated telling us that he is waiting for C programmers to die off. I have recently started to browse through the "MER analyst notebook" (http://anserver1.eprsl.wustl.edu/). MER stands for Mars Exploration Rover, the two spaceships that NASA sent to Mars. In the logs of the activity we find lines like:
3
1690
by: LW | last post by:
"Consider the U.S. government's recognition and protection of intellectual property in the computer industry. Inventors of computer hardware were able to patent their inventions, and the government realized that creators of software also had the right to copyright their software. If the government had not protected these property rights, the computer revolution would not have occurred." had a RIGHT to protect their intellectual...
2
1230
nomad
by: nomad | last post by:
Hello Everyone: I back trying to learn Java again. Here is what I'm trying to do. 1. How does the code inside the visitPennsylvania method refer to the variable with vale "red Planet". I know to that you need to use. this. But I can not figure out how to use it. Here are my two class. import static java.lang.System.out; public class EnglishSpeakingWorld { String mars = " red planet";
4
318
by: jacob navia | last post by:
The Mars lander Phoenix uses the best language for the job. Here is an excerpt of the interview of O'Reilly with Peter Gluck, NASA software engineer. <quote> That's right. Yeah. The spacecraft software is entirely in C. C? Really? That surprises me a little bit.
32
2560
by: jhc0033 | last post by:
Interesting article I came across on Slashdot: http://developers.slashdot.org/developers/08/07/10/213211.shtml They are using C at JPL to program Mars Lander and just about everything now! Not Ada. Anyone got an explanation? I wonder also, do they really mean C++ when they say C. In my experience, this is a frequent, although disagreeable usage.
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.