[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 1d84f05: MakeCatalog: labels that aren't prese
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 1d84f05: MakeCatalog: labels that aren't present in image won't be parsed |
Date: |
Mon, 4 Nov 2019 10:43:04 -0500 (EST) |
branch: master
commit 1d84f05332502c93dd09aa447cd4741bb9d9714b
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
MakeCatalog: labels that aren't present in image won't be parsed
MakeCatalog works by defining tiles over the individual labels of the
dataset and only parsing those tiles for each label in parallel. Also,
MakeCatalog assumes all integers until the largest integer in the image are
a label. Therefore, when a given label doesn't exist in the image,
MakeCatalog should actually set a tile size of 0 elements.
But this wasn't happening: to find the tiles of each label, we were
effectively assuming the largest possible tile, then shrinking it to fit
over the given label. Therefore, when a label/integer didn't exist in an
image, its tile would be larger than the actual input image size and could
cause a segmentation fault.
With this commit, before defining the tiles, we make sure that their
regions have actually been set. If they haven't, the tile's size will be
set to zero.
This fixes bug #57164.
---
NEWS | 1 +
bin/mkcatalog/ui.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/NEWS b/NEWS
index 71d33e6..c000c11 100644
--- a/NEWS
+++ b/NEWS
@@ -118,6 +118,7 @@ See the end of the file for license conditions.
bug #56999: Compilation error on macOS 10.9 not recognizing AT_FDCWD.
bug #57057: BuildProgram not using environment LDFLAGS or CPPFLAGS.
bug #57101: Crop segmentation fault when no overlap exists in image-mode.
+ bug #57164: MakeCatalog crashes when a label isn't in the dataset.
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index fcdae2a..33d1514 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -1396,6 +1396,16 @@ ui_one_tile_per_object(struct mkcatalogparams *p)
}
while(++l<lf);
+ /* If an label doesn't exist in the image, then set the minimum and
+ maximum values to zero. */
+ for(i=0;i<p->numobjects;++i)
+ for(d=0;d<ndim;++d)
+ {
+ if( minmax[ i * width + d ] == GAL_BLANK_SIZE_T
+ && minmax[ i * width + ndim + d ] == 0 )
+ minmax[ i * width + d ] = minmax[ i * width + ndim + d ] = 0;
+ }
+
/* For a check.
for(i=0;i<p->numobjects;++i)
printf("%zu: (%zu, %zu) --> (%zu, %zu)\n", i+1, minmax[i*width],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 1d84f05: MakeCatalog: labels that aren't present in image won't be parsed,
Mohammad Akhlaghi <=