[gdal-dev] Potential bug with the create function for the "GTiff" driver

Adeel Raza adeel.raza at crc.gc.ca
Thu Jul 9 11:06:26 EDT 2009


Hi Frank,

To answer your questions:

-    " I presume you inspected the member values in the visual studio
    debugging environment?  I suspect you have some sort of versioning
    mixup - perhaps you have compiled your mainline using a different
    version of the include files than correctly apply to the DLL you
    end up invoking. "
Yes I did inspect the member values in the visual studio debugging 
environment. I'm not exactly sure what you mean by the second line, but 
if you mean that my DLL has been compiled from a different version of 
GDAL than from my import library than that is incorrect. I compiled both 
the import library and the DLL using the gdal 1.6.1 source code and I 
set the MSVC_VER variable to 1500 in the "nmake.opt" file so that the 
"nmake /f makefile.vc" file would compile the library for the MSVC9.0.

-   " Alternatively, the debugger is getting confused
    due to different structure packing options being used in your
    main project compared to what was used in building GDAL itself.  "
I have no idea what the structure packing options for GDAL or my project 
are or how to find out what they are? Any pointers in this area would be 
useful.

-   "Is the created TIFF correct (if you close it)?"
No. I used GDALClose() to close the .tif file and then I opened it using 
GDALOpen() and most of the data members retained their original values 
except the following data members which changed to the indicated values:
nBands = 19036392;
bShared = 19076432;

-   "If you are having
    trouble getting compatible build options between your application
    and the underlying library you may find it safer to use only the
    GDAL C API instead of the C++ API in order to avoid subtle issues."
I'll keep that in mind. Thanks.

Thanks Frank.

Best Regards,
Adeel.

Frank Warmerdam wrote:
> Adeel Raza wrote:
>> Hi,
>>
>> I'm using gdal 1.6.1 for MSVC9.0 on Windows XP (32-bit platform). I'm 
>> trying to create a .tif file according to the following code:
>>
>>    GDALDriver *tifDriver;
>>    GDALDataset *srcDataset;
>>
>>    tifDriver = (GDALDriver *)GDALGetDriverByName("GTiff");
>>    assert(tifDriver != NULL);
>>    srcDataset = tifDriver->Create("srcDataset.tif", nCols, nRows, 1, 
>> GDALDataType::GDT_Float32, NULL);
>>    assert(srcDataset != NULL);
>>
>>
>> "nCols" is defined as an unsigned short and has a value of 2460. 
>> Similarly "nRows" is also defined as an unsigned short and has a 
>> value of 2430.
>> When I run the code shown above the asserts do not fail. The returned 
>> dataset however, has wrong values assigned to its data members. The 
>> values for the data members of "srcDataset" are as follows:
>>
>> eAccess = 2460;
>> nRasterXSize = 2430;
>> nRasterYSize = 1;
>> nBands = 19035560;
>> papoBands = 0X00000000;
>> bForceCahcedIO = 1
>> nRefCount = 0;
>> bShared = 0;
>>
>> The values for nRasterXSize, nRasterYSize, and nBands are wrong (I'm 
>> not sure about the other data members), and should be as follows:
>> nRasterXSize = 2460;
>> nRasterYSize = 2430;
>> nBands = 1;
>>
>> Is this a bug in the create function for the "GTiff" driver or am I 
>> doing something wrong?
>
> Adeel,
>
> I presume you inspected the member values in the visual studio
> debugging environment?  I suspect you have some sort of versioning
> mixup - perhaps you have compiled your mainline using a different
> version of the include files than correctly apply to the DLL you
> end up invoking.  Alternatively, the debugger is getting confused
> due to different structure packing options being used in your
> main project compared to what was used in building GDAL itself.
>
> Is the created TIFF correct (if you close it)?  If you are having
> trouble getting compatible build options between your application
> and the underlying library you may find it safer to use only the
> GDAL C API instead of the C++ API in order to avoid subtle issues.
>
> Best regards,
>



More information about the gdal-dev mailing list