IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41521 for trunk


Ignore:
Timestamp:
Apr 2, 2021, 2:14:14 PM (5 years ago)
Author:
eugene
Message:

remove extensive memory corruption tests which were caused by the glibc / kernel malloc problem

Location:
trunk/psLib/src/fits
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFits.c

    r36364 r41521  
    773773    int status = 0;                     // cfitsio status
    774774    int comptype = 0;                   // cfitsio compression type
     775
    775776    if (fits_get_compression_type(fits->fd, &comptype, &status)) {
    776777        psFitsError(status, true, "Unable to get compression type.");
  • trunk/psLib/src/fits/psFitsImage.c

    r41504 r41521  
    292292                                          psRandom *rng, // Random number generator
    293293                                          bool newScaleZero // Determine a new BSCALE and BZERO?
    294                                           )
     294    )
    295295{
    296296    psAssert(bscale, "impossible");
     
    307307
    308308    psFitsOptions *options = fits->options; // Options for FITS writing
    309 
    310     // psMemCheckCorruption (stderr, true); // 1
    311309
    312310    // Can't PLIO compress U16,U32,U64 directly, so convert them
     
    331329    }
    332330
    333     // psMemCheckCorruption (stderr, true); // 1x
    334 
    335331    // Custom floating-point
    336332    if (PS_IS_PSELEMTYPE_REAL(image->type.type) && options->conventions.psBitpix &&
     
    345341    }
    346342
    347     // psMemCheckCorruption (stderr, true); // 2
    348 
    349343    // Quantise floating-point images
    350344    if (PS_IS_PSELEMTYPE_REAL(image->type.type) && options->bitpix > 0) {
    351         if (newScaleZero) {
     345        if (newScaleZero) {
    352346            // Choose an appropriate BSCALE and BZERO
    353347            if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) {
     
    357351                return psMemIncrRefCounter((psImage*)image);
    358352            }
    359         } else {
     353        } else {
    360354            // Don't want to muck with the current BSCALE and BZERO.  Get the current values and use those.
    361355            int status = 0;                 // Status of cfitsio
    362356            if (fits_read_key_dbl(fits->fd, "BSCALE", bscale, NULL, &status) && status != KEY_NO_EXIST) {
    363                 psFitsError(status, true, "Unable to read header.");
    364                 return NULL;
     357                psFitsError(status, true, "Unable to read header.");
     358                return NULL;
    365359            }
    366 
    367             // psMemCheckCorruption (stderr, true); // 2x
    368360
    369361            status = 0;
    370362            if (fits_read_key_dbl(fits->fd, "BZERO", bzero, NULL, &status) && status != KEY_NO_EXIST) {
    371                 psFitsError(status, true, "Unable to read header.");
    372                 return NULL;
     363                psFitsError(status, true, "Unable to read header.");
     364                return NULL;
    373365            }
    374366            status = 0;
    375367            if (*bscale == 0.0) {
    376                 psError(PS_ERR_IO, true,
    377                         "Supposed to use old values of BSCALE and BZERO, but they don't exist.");
    378                 return NULL;
     368                psError(PS_ERR_IO, true,
     369                        "Supposed to use old values of BSCALE and BZERO, but they don't exist.");
     370                return NULL;
    379371            }
    380 
    381             // psMemCheckCorruption (stderr, true); // 3
    382 
    383         }
    384 
    385         // XXX this test triggers the pswarp memory corruption problem.  you need to include "psThread.h" above to activate this
    386         // for (int nx = 0; nx < 3; nx++) {
    387         //     psList *pending = psThreadGetPendingQueue();
    388         //     if (pending && pending->head) {
    389         //      fprintf (stderr, "thread jobs are still pending...\n");
    390         //     }
    391         //     // XXX can we mess up the memory?
    392         //     psImage *temp1 = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
    393         //     fprintf (stderr, "corruption check set 1\n");
    394         //     psMemCheckCorruption (stderr, true);
    395         //     psImageInit (temp1, 2.0);
    396         //     psFree (temp1);
    397         //     fprintf (stderr, "corruption check set 2\n");
    398         //     psMemCheckCorruption (stderr, true);
    399         // }
    400 
    401         // fprintf (stderr, "corruption check psFitsInsertImageWithMask\n");
    402         // psMemCheckCorruption (stderr, true);
    403 
     372        }
    404373        psImage *out = psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng);
    405374        return out;
     
    407376
    408377    // Choose the appropriate output type, given the input type and desired bits per pixel
    409 #define CONVERT_TYPE_INT_CASE(OUTTYPE, INTYPE, BITPIX) \
    410   case BITPIX: \
    411     OUTTYPE = PS_IS_PSELEMTYPE_UNSIGNED(INTYPE) ? PS_TYPE_U##BITPIX : PS_TYPE_S##BITPIX; \
     378#define CONVERT_TYPE_INT_CASE(OUTTYPE, INTYPE, BITPIX)                  \
     379    case BITPIX:                                                        \
     380        OUTTYPE = PS_IS_PSELEMTYPE_UNSIGNED(INTYPE) ? PS_TYPE_U##BITPIX : PS_TYPE_S##BITPIX; \
    412381    break;
    413 #define CONVERT_TYPE_FLOAT_CASE(OUTTYPE, BITPIX) \
    414   case -BITPIX: /* Note the use of the negative sign */ \
    415     OUTTYPE = PS_TYPE_F##BITPIX; \
     382#define CONVERT_TYPE_FLOAT_CASE(OUTTYPE, BITPIX)                \
     383    case -BITPIX: /* Note the use of the negative sign */       \
     384        OUTTYPE = PS_TYPE_F##BITPIX;                            \
    416385    break;
    417386
    418 
    419     // psMemCheckCorruption (stderr, true); // 4
    420387
    421388    *bscale = 1.0;
     
    501468
    502469    // No need to apply the BSCALE, BZERO because cfitsio does this for us
    503 
     470   
    504471    return true;
    505472}
     
    668635    }
    669636
    670     // fprintf (stderr, "calling psFitsInsertImageWithMask for %s, %lx, %lx\n", fits->fd->Fptr->filename, (long int) image, (long int) mask);
    671 
    672637    int numCols = image->numCols;       // Number of columns for image
    673638    int numRows = image->numRows;       // Number of rows for image
     
    682647    psFitsFloat floatType;              // Custom floating-point convention type
    683648
    684     // psMemCheckCorruption (stderr, true);
    685 
    686649    psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType,
    687650                                                   fits, image, mask, maskVal, NULL, true); // Image to write out
    688 
    689     // psMemCheckCorruption (stderr, true);
    690 
    691     // fprintf (stderr, "allocated in psFitsInsertImageWithMask %s, %lx\n", fits->fd->Fptr->filename, (long int) diskImage);
    692651
    693652    if (!diskImage) {
     
    726685
    727686    psFitsOptions *options = fits->options; // FITS I/O options
    728 /*     if (options) { */
    729 /*       if (options->scaling == PS_FITS_SCALE_LOG_RANGE) { */
    730 /*      fprintf(stderr,"it has the scaling I expect\n"); */
    731 /*       } */
    732 /*       else { */
    733 /*      fprintf(stderr,"it does nto have the scaling I expect\n"); */
    734 /*       } */
    735 /*     } */
    736 /*     else { */
    737 /*       fprintf(stderr,"options is null, apparently? \n"); */
    738 /*     } */
    739687     
    740688    psAssert(!useRequestedScale || !options || bitPix == options->bitpix || options->bitpix == 0,
     
    830778
    831779    if (isfinite(bzero) && isfinite(bscale) && (bscale != 0.0)) {
    832         fits_write_key_dbl(fits->fd, "BZERO", bzero, 12,
     780        fits_write_key_dbl(fits->fd, "BZERO", bzero, 12,
    833781                           "Scaling: TRUE = BZERO + BSCALE * DISK", &status);
    834782        fits_write_key_dbl(fits->fd, "BSCALE", bscale, 12,
     
    885833    if (image->parent == NULL) {
    886834        // if no parent, assume that the image data is contiguous
    887         fits_write_img(fits->fd, dataType, 1, numCols*numRows, diskImage->data.V[0], &status);
     835        fits_write_img(fits->fd, dataType, 1, numCols*numRows, diskImage->data.V[0], &status);
    888836    } else {
    889837        // image data may not be contiguous; write one row at a time
  • trunk/psLib/src/fits/psFitsScale.c

    r41505 r41521  
    131131    psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object
    132132    double mean, stdev;                                    // Mean and standard deviation
     133
    133134    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) {
    134135        // It could be because the image is entirely masked, in which case we don't want to error
     
    919920      case PS_FITS_SCALE_STDEV_NEGATIVE:
    920921      case PS_FITS_SCALE_STDEV_BOTH:
    921         if (!scaleStdev(bscale, bzero, image, mask, maskVal, options)) {
     922        if (!scaleStdev(bscale, bzero, image, mask, maskVal, options)) {
    922923            psError(PS_ERR_UNKNOWN, false, "Unable to set BSCALE and BZERO from stdev");
    923924            return false;
    924         }
     925        }
    925926        break;
    926927      case PS_FITS_SCALE_LOG_RANGE:
Note: See TracChangeset for help on using the changeset viewer.