[sac-dev] bugs found

Brian Savage savage13 at dtm.ciw.edu
Fri Jun 30 08:19:21 PDT 2006


All,

A few more bugs were found in sac.  They have been fixed and should be
available in the next release.  They are not in the repository yet, but
will be soon.

All of these bug are short, quick fixes.  Please email me and I will
send you the appropriate files.

Bug List: ( explanations below )
- Memory Leak Bug
- Power of 2 Bug
- read more Bug

Cheers,
Brian

Memory Leak Bug:
-------------------------
Multiple read commands exposes a memory leak which can become very
large, very quickly.  I found this bug by unwittingly consuming 4 GB of
memory while processing a large dataset.

Example:
SAC> read file1
SAC> read file2
...
SAC> read filen

Fix:
The allocated memory for storing the sac data was not freed when
executing another read call, not read more.  Calls to relamb were
included which releases memory or frees it back to the system.  this was
done in dfm/readfl().

Power of 2 Bug:
-----------------------
Determining the next largest power of 2 for numbers slightly larger than
a power of 2 returns the smaller power of 2.  The bug is in ucf/next2().
 It can cause memory error and buffer overruns, causing sac to crash or
experience unexpected behavior.

Example:
Number of points: 8193
Get next largest power of 2: (should be 16384)
ucf/next2() returns 8192

Fix:
The cause of the bug was a rounding error of a real number to an
integer.  A call to ceil() fixes the bug, plus a check to make certain
the returned power of 2 is larger than the initial number of points.

read more Bug:
-----------------------
While reading a large number of files into sac using the "read more",
sac grinds to a halt.  The problem was found in the SeisMgr code as it
was looping over the list of files during each read more command.

Example:
SAC> read more file1
SAC> read more file2
...
SAC> read more filen

Fix:
No fix for this bug has been found, but turning off the SeisMgr code
essentially fixes the problem and does not harm to the working of sac.
My working copy has an environment variable to indicate whether or not
to use the SeisMgr code.  I am not certain what the advantages the
SeisMgr code provides the sac code.  If someone has a list of the
benefits that would be great.  The recall bug, still not fixed, is due
to the same section of code.




More information about the sac-dev mailing list