EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Cute error in alh/file.c
From: Tony Cox - (415)926-3105 <[email protected]>
To: [email protected]
Date: Thu, 27 Jul 1995 14:15:08 PST
Here's a cute little error which has been around in alh/file.c for some
years:-

-----------

char *shortfile(name)
char *name;
{
int len,i;
char *shortname;

	len = strlen(name);
	shortname = name;
    while (len != 0) {
        if(*(name+len)== '/') {
            shortname = name+len+1;
            break;
        }
        len--;
    }
}

-----------


Notice that there is no return statement? I can only assume that the compilers
for Sun and HP have `accidentally' optimized 'char *shortname' into the 
register which is used to return the result. The DECC compiler on the Alpha
doesn't complain about this construction (do the others?), but the routine
returns junk which causes a segmentation fault.

I bring this up not to embarrass the authors, but to point out that as we
expand support onto other architectures, working code with hidden bugs may
well cause `hard to diagnose' problems. This time, the failure was obvious and
easily fixed. In new IOC implementations (in particular), this type of error
could cause reliability problems, even equipment failure.

I'm not sure what mechanism are in place to `validate' new code. SunSoft have
found that `code reading' sessions are a good idea. Several folks sit around
a table (presumably with pizza's and beer), and just read through the listings
together. They find this to be safer than traditional debugging sessions.
Perhaps we should so the same??

Regards
Tony

--------------------------------------------------------------------------------
Dr Anthony D Cox
Computer Systems Specialist
Stanford Synchrotron Radiation Laboratory
Stanford Linear Accelerator Center
MS 69, Box 4349
Stanford CA 94305
[email protected]
--------------------------------------------------------------------------------


Navigate by Date:
Prev: CAPFAST symbol for WAIT record Andy Foster
Next: Announcing ezcaIDL, a new extension Mark Rivers
Index: 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: CAPFAST symbol for WAIT record Andy Foster
Next: Re: Cute error in alh/file.c Marty Kraimer
Index: 1994  <19951996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·