IUBio GIL .. BIOSCI/Bionet News .. Biosequences .. Software .. FTP

ReadSeq Bug

Michael Yasayko yasayko at darwin.com
Wed Apr 2 20:21:43 EST 1997

I've discovered a potentially fatal bug in the Feb 1 1993 release of
"ReadSeq".  ReadSeq, authored by Don Gilbert of Indiana University,
conveniently converts between most of the major sequence file types that
people have developed over the years.  ReadSeq is available at:


On modern machines, the bug typically shows up only in large sequence
files.	Nonetheless, the bug can theoretically affect files of any
length.  The most common manifestation of the bug on our Solaris 2.4
machines is a "segmentation fault".

The bug is in "ureadseq.c" line 1480.  The following changes will fix it;
the diff command line was:

  diff "original" "fixed"

In other words, the code lines following the "<"s needs to be replaced
with the code lines following the ">"s:

] diff ureadseq.c ../../readseqd/ureadseq.c
<   while (n--) c = crctab[((int)c ^ (to_upper(*seq++))) & 0xff] ^ (c >>
>   while (n--) {
>      c = crctab[((int)c ^ (to_upper(*seq))) & 0xff] ^ (c >> 8);
>      seq++;
>   }

Technical notes on why this is a bug:

"to_upper" is a preprocessor macro, not a function.  The macro makes use
of the argument parameter twice within the macro body:

  #define to_upper(c) ((char)(is_lower(c) ? (c)-' ' : (c)))

Hence, placing a variable along with the increment operator (*seq++) into
the macro arg list yields code which increments "seq" twice per iteration
of the "while" loop, not just once as intended.  Hence, the code skips
over every second character in the sequence, eventually running past the
end of the allocated memory for "char *seq".

My guess is that the bug is also making the "checksum" results invalid,
although I could be mistaken as I don't know how this particular
"checksum" really works.


Mike Yasayko, Scientific Programmer, Darwin Molecular Corporation
E-mail:  yasayko at darwin.com

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

More information about the Bio-soft mailing list

Send comments to us at archive@iubioarchive.bio.net