-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[argparse][gdal_rasterize] Port to arg parser #10741
Conversation
elpaso
commented
Sep 6, 2024
•
edited
Loading
edited
Co-authored-by: Even Rouault <even.rouault@spatialys.com>
I'm getting a segmentation fault since (I believe) this update, when using
|
@elpaso Can you have a look at that ? |
@tbonfort I cannot reproduce, can you please provide a small data sample and the command line to reproduce the crash? |
@elpaso there is no sample data per se, this is raised during the CI in https://github.com/airbusgeo/godal/blob/203295be1c72687019cbe7774ea02eb0c84fe489/godal_test.go#L2405 |
@tbonfort I've tried to replicate your go unit test with the following, but it works fine for me
|
It seems to be the repetition of using the/an arg parser that causes the issue. I finally managed to reproduce the segfault with #include <gdal.h>
#include <gdal_utils.h>
#include <ogr_srs_api.h>
int main(int argc, char **argv) {
GDALAllRegister();
GDALDatasetH vec = GDALOpenEx("GEOJSON:{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}}", GDAL_OF_VECTOR, NULL, NULL, NULL);
GDALDriverH memd = GDALGetDriverByName("MEM");
GDALDatasetH memds = GDALCreate(memd,"",3,3,3,GDT_Byte,NULL);
double gt[] = { 0, 1, 0, 1, 0, -1 };
GDALSetGeoTransform(memds,gt);
for(int i=1; i<=3; i++) {
GDALFillRaster(GDALGetRasterBand(memds,i),255,0);
}
OGRSpatialReferenceH sr = OSRNewSpatialReference(NULL);
OSRSetAxisMappingStrategy(sr, OAMS_TRADITIONAL_GIS_ORDER);
OSRImportFromEPSG(sr, 4326);
GDALSetSpatialRef(memds,sr);
char *switches[] = {NULL};
GDALRasterizeOptions *ropts = GDALRasterizeOptionsNew(switches,NULL);
int rerr;
GDALRasterize(NULL,memds,vec,ropts,&rerr);
char *switches2[] = {"-burn","0",NULL};
ropts = GDALRasterizeOptionsNew(switches2,NULL);
GDALRasterize(NULL,memds,vec,ropts,&rerr);
}``` |
Actually it seems it is the lack of any command line argument, since I reproduce the crash with:
|
Correct, it's the empty arg list alone that's causing the issue. #include <gdal.h>
#include <gdal_utils.h>
int main(int argc, char **argv) {
GDALAllRegister();
GDALDatasetH vec = GDALOpenEx("GEOJSON:{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}}", GDAL_OF_VECTOR, NULL, NULL, NULL);
GDALDriverH memd = GDALGetDriverByName("MEM");
GDALDatasetH memds = GDALCreate(memd,"",3,3,3,GDT_Byte,NULL);
char *switches[] = {NULL};
GDALRasterizeOptions *ropts = GDALRasterizeOptionsNew(switches,NULL);
int rerr;
GDALRasterize(NULL,memds,vec,ropts,&rerr);
} |