IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39396 for trunk


Ignore:
Timestamp:
Feb 26, 2016, 6:21:57 AM (10 years ago)
Author:
eugene
Message:

plug memleaks; trying to catch some (possible) stack and heap overflow errors: adding padding to allocated config regions, using scan_line_maxlen

Location:
trunk/Ohana/src/relastro
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relastro/include/relastro.h

    r39390 r39396  
    415415void SetProtect (int mode);
    416416int SetSignals (void);
     417
     418void relastro_client_free ();
    417419
    418420GSCRegion    *find_regions        PROTO((Image *image, off_t Nimage, int *Nregions, GSCRegion *fullregion));
     
    610612int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog);
    611613int BrightCatalogSplitFree (CatalogSplitter *catalogs);
     614void BrightCatalogFree (BrightCatalog *bcatalog);
    612615
    613616PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve);
     
    774777double weight_cauchy (double x);
    775778double dpsi_cauchy (double x);
     779void my_memdump (char *message);
  • trunk/Ohana/src/relastro/src/BrightCatalog.c

    r39383 r39396  
    357357
    358358    ohana_memcheck (1);
     359
     360    my_memdump("start of define_bintable");
    359361    gfits_define_bintable_column (&theader, "D", "RA",       "ra",                         "degrees", 1.0, 0.0);
     362    my_memdump("after define_bintable RA");
     363
    360364    gfits_define_bintable_column (&theader, "D", "DEC",      "dec",                        "degrees", 1.0, 0.0);
     365    my_memdump("after define_bintable DEC");
     366
    361367    gfits_define_bintable_column (&theader, "E", "MAG_SYS",  "magnitude (sys)",             NULL,    1.0, 0.0);
    362368    gfits_define_bintable_column (&theader, "E", "MAG_CAL",  "magnitude (cal)",             NULL,    1.0, 0.0);
     
    771777}
    772778
     779void BrightCatalogFree (BrightCatalog *bcatalog) {
     780  if (!bcatalog) return;
     781  FREE (bcatalog[0].average);
     782  FREE (bcatalog[0].measure);
     783  FREE (bcatalog[0].secfilt);
     784  FREE (bcatalog);
     785  return;
     786}
     787
    773788// distribute a bright catalog across separate catalogs
    774789CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt) {
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r39375 r39396  
    44
    55  char  *config, *file;
    6   char CatdirPhotcodeFile[256];
     6  char CatdirPhotcodeFile[DVO_MAX_PATH];
    77  struct stat filestat;
    88  int status;
     
    6161  ScanConfig(config, "WHERE_B",                "%s",  0, WHERE_B);
    6262
    63   sprintf (ImageCat, "%s/Images.dat", CATDIR);
     63  snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", CATDIR);
    6464
    6565  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) SKY_DEPTH = 2;
     
    7777
    7878  /* update master photcode table if not defined */
    79   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     79  snprintf (CatdirPhotcodeFile, DVO_MAX_PATH, "%s/Photcodes.dat", CATDIR);
    8080  if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
    8181    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
     
    9191  }
    9292
     93  FreeConfigFile();
    9394  free (config);
    9495  free (file);
  • trunk/Ohana/src/relastro/src/SetSignals.c

    r13322 r39396  
    5252  return (TRUE);
    5353}
     54
     55void my_memdump (char *message) {
     56
     57  fprintf (stderr, "%s\n", message);
     58  pid_t myPid = getpid();
     59  char line[256];
     60  snprintf (line, 256, "cat /proc/%d/maps", myPid);
     61  system (line);
     62  fprintf (stderr, "-------------------- end ---------------------\n");
     63  return;
     64}
     65
    5466/*
    5567
  • trunk/Ohana/src/relastro/src/args.c

    r39390 r39396  
    920920  if (argc != 1) usage_client ();
    921921  return TRUE;
     922}
     923
     924void relastro_client_free () {
     925  FREE (PHOTCODE_SKIP_LIST);
     926  FREE (PHOTCODE_KEEP_LIST);
     927  FREE (PHOTCODE_RESET_LIST);
     928  FREE (DCR_RED_COLOR_POS);
     929  FREE (DCR_RED_COLOR_NEG);
     930  FREE (DCR_BLUE_COLOR_POS);
     931  FREE (DCR_BLUE_COLOR_NEG);
     932
     933  FREE(PHOTCODE_A_LIST);
     934  FREE(PHOTCODE_B_LIST);
     935  FREE(HIGH_SPEED_DIR);
     936  FREE(BCATALOG);
     937  FREE (HOSTDIR);
    922938}
    923939
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r39225 r39396  
    9292    }
    9393    Ncat ++;
     94
     95    char message[1024];
     96    snprintf (message, 1024, "loaded catalog: %d", Ncat);
     97    my_memdump(message);
    9498  }
    9599
  • trunk/Ohana/src/relastro/src/plotstuff.c

    r30616 r39396  
    2525  char name[100];
    2626
    27   sprintf (name, "gastro [%d]", N);
     27  snprintf (name, 100, "gastro [%d]", N);
    2828  Xgraph[N] = KapaOpen ("kapa", name);
    2929
  • trunk/Ohana/src/relastro/src/relastro_client.c

    r39379 r39396  
    11# include "relastro.h"
     2// # include <sys/types.h>
     3// # include <unistd.h>
    24
    35// relastro_client is run on a remote host and is responsible for updating the catalogs
     
    2123int main (int argc, char **argv) {
    2224
     25  my_memdump("start of program");
     26
    2327  // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc)
    2428  SetSignals ();
     
    2832  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2933  SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
     34
     35  my_memdump("done config");
    3036
    3137  switch (RELASTRO_OP) {
     
    3945        exit (2);
    4046      }
     47      my_memdump("loaded catalogs");
     48
    4149      BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog);
     50      my_memdump("merged bcatalog");
     51
    4252      if (!BrightCatalogSave (BCATALOG, bcatalog)) {
    4353        fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);
    4454        exit (2);
    4555      }
     56
     57      SkyTableFree (sky);
     58      SkyListFree(skylist);
     59      FreePhotcodeTable();
     60
     61      int i;
     62      for (i = 0; i < Ncatalog; i++) {
     63        dvo_catalog_free (&catalog[i]);
     64      }
     65      FREE (catalog);
     66      BrightCatalogFree(bcatalog);
     67
     68      relastro_client_free ();
     69      FREE(photcodesKeep);
     70      FREE(photcodesSkip); 
     71      FREE(photcodesReset);
     72      FREE(photcodesGroupA);
     73      FREE(photcodesGroupB);
     74
     75      ohana_memcheck (TRUE);
     76      ohana_memdump (TRUE);
    4677      break;
    4778    }
Note: See TracChangeset for help on using the changeset viewer.