Thread: Bug fix for xcorrelate.c - passing wrong parameters to cross_correlation_normalized()

Started: 2011-09-16 23:23:54
Last activity: 2011-09-19 17:44:06
Topics: SAC Developers
Hi all,
I would like to report a bug: when you call the SAC command "CORRELATE" using the key "NORMALIZED", a segmentation fault occurs.

The problem is due to calling the function cross_correlation_normalized(), in xcorrelate.c:292, passing erroneously the variables "nlenmx" and "nfft". In fact, the function declaration in inc/dbh.h shows that it is necessary passing the pointers to those variable.

void cross_correlation_normalized(float *data1,
float *data2,
int *npts_data,
float *xcorr,
int *npts_xcorr);

I attach below my proposed bug fix.

Regards,
Matteo


============================================================
diff -p -r sac-101.4/src/sam/xcorrelate.c sac-101.4-changed/src/sam/xcorrelate.c
*** sac-101.4/src/sam/xcorrelate.c Thu Mar 26 21:30:19 2009
--- sac-101.4-changed/src/sam/xcorrelate.c Fri Sep 16 15:53:00 2011
*************** L_1200:
*** 252,260 ****
if(correlation_normalized) {
cross_correlation_normalized(cmmem.sacmem[ndxmas],
cmmem.sacmem[ndxsig],
! nlenmx,
cmmem.sacmem[ndxcor],
! nfft);
}
/* -- Perform a circular shift to align the correlation in the output block. */
/* overhauled to allow full range of correlation. maf 961204 */
--- 252,260 ----
if(correlation_normalized) {
cross_correlation_normalized(cmmem.sacmem[ndxmas],
cmmem.sacmem[ndxsig],
! &nlenmx,
cmmem.sacmem[ndxcor],
! &nfft);
}
/* -- Perform a circular shift to align the correlation in the output block. */
/* overhauled to allow full range of correlation. maf 961204 */

  • Dear Matteo,

    Thanks for the simple fix. This will be included in the upcoming version 101.5.

    Brian Savage
    savage<at>uri.edu

    On Sep 16, 2011, at 10:23 AM, Matteo Quintiliani wrote:

    Hi all,
    I would like to report a bug: when you call the SAC command "CORRELATE" using the key "NORMALIZED", a segmentation fault occurs.

    The problem is due to calling the function cross_correlation_normalized(), in xcorrelate.c:292, passing erroneously the variables "nlenmx" and "nfft". In fact, the function declaration in inc/dbh.h shows that it is necessary passing the pointers to those variable.

    void cross_correlation_normalized(float *data1,
    float *data2,
    int *npts_data,
    float *xcorr,
    int *npts_xcorr);

    I attach below my proposed bug fix.

    Regards,
    Matteo


    ============================================================
    diff -p -r sac-101.4/src/sam/xcorrelate.c sac-101.4-changed/src/sam/xcorrelate.c
    *** sac-101.4/src/sam/xcorrelate.c Thu Mar 26 21:30:19 2009
    --- sac-101.4-changed/src/sam/xcorrelate.c Fri Sep 16 15:53:00 2011
    *************** L_1200:
    *** 252,260 ****
    if(correlation_normalized) {
    cross_correlation_normalized(cmmem.sacmem[ndxmas],
    cmmem.sacmem[ndxsig],
    ! nlenmx,
    cmmem.sacmem[ndxcor],
    ! nfft);
    }
    /* -- Perform a circular shift to align the correlation in the output block. */
    /* overhauled to allow full range of correlation. maf 961204 */
    --- 252,260 ----
    if(correlation_normalized) {
    cross_correlation_normalized(cmmem.sacmem[ndxmas],
    cmmem.sacmem[ndxsig],
    ! &nlenmx,
    cmmem.sacmem[ndxcor],
    ! &nfft);
    }
    /* -- Perform a circular shift to align the correlation in the output block. */
    /* overhauled to allow full range of correlation. maf 961204 */
    _______________________________________________
    sac-dev mailing list
    sac-dev<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-dev



06:05:15 v.f0c1234e