Thread: bugs found

Started: 2006-06-30 18:19:21
Last activity: 2006-06-30 18:19:21
Topics: SAC Developers
Brian Savage
2006-06-30 18:19:21
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.



  • Peter Goldstein
    2006-06-30 16:17:10

    Brian,

    Nice work fixing these bugs.

    FYI, the SeisMgr code is essential when using a relational database
    as is done by the GNEM program at LLNL.
    While it isn't something that is currently useful to the IRIS
    community, it seems to me that it would be
    good to try and maintain this capability at some level so that it can
    be utilized should it be needed.
    Given the growing DMC archive and the amount of data coming available
    from USArray I would think
    that this is a realistic possibility.

    Using an environment variable to turn it on or off seems like a good
    way to keep it in the code without
    impacting those who don't use it.

    Cheers,

    Peter


    At 11:19 AM -0400 6/30/06, Brian Savage wrote:
    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.


    _______________________________________________
    sac-dev mailing list
    sac-dev<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-dev


    --

    Peter Goldstein, Ph.D. (925) 423-1231 (office)
    L-103, PO Box 808 (925) 422-5844 (fax)
    Livermore, CA 94551 peterg<at>llnl.gov (email)
    web page: http://www.llnl.gov/sac

01:02:21 v.22510d55