Ticket #1712 (closed defect: fixed)

Opened 1 year ago

Last modified 11 months ago

Problems writing rasters with NG Python on 64 bit machines

Reported by: gillins Assigned to: warmerdam
Priority: high Milestone: 1.4.3
Component: PythonBindings Version: 1.4.2
Severity: normal Keywords: 64bit
Cc: hobu

Description

in gdal_wrap.cpp, both _wrap_Dataset_WriteRaster and _wrap_Band_WriteRaster contain code like this:

PyString?_AsStringAndSize(obj5, &arg7, ( Py_ssize_t*)&arg6 );

Where arg6 is an integer. On a 64 bit machine, int is 32 bits while a pointer is 64. So, this cast is not valid because they are different sizes. This may well work on a little endian machine, but on a big endian machine, the 'wrong' part of the pointer gets written to the int (which is zero) and the bindings fail to write anything.

A proposed workaround patch (against 1.4.2) is supplied.

This makes me wonder if using 'int' as a size is a good idea - what happens if I want to write a raster > 4GB?

Thanks,

Sam.

Attachments

gdal_wrap_64patch.cpp (1.6 kB) - added by gillins on 07/25/07 22:29:44.
Proposed 64 bit workaround

Change History

07/25/07 22:29:44 changed by gillins

  • attachment gdal_wrap_64patch.cpp added.

Proposed 64 bit workaround

08/04/07 22:11:10 changed by warmerdam

  • owner changed from hobu to warmerdam.
  • cc set to hobu.

I'll take this since I have a convenient test environment for the ticket.

08/04/07 23:12:37 changed by warmerdam

  • keywords set to 64bit.
  • status changed from new to closed.
  • resolution set to fixed.

I have applied a variation of this patch in swig/include/python/typemaps_python.i.

Changes applied in trunk (r1712) and 1.4 branch (r1713).

I agree that use of int's does limit the size of chunks that can be written to 2GB but it is certainly possible to manipulate larger rasters in pieces.

08/23/07 17:51:39 changed by warmerdam

Garr, it seems I botched this in 1.4 (r11951) and trunk (r11952).