Ticket #1712 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Problems writing rasters with NG Python on 64 bit machines

Reported by: gillins Owned by: 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 Download (1.6 KB) - added by gillins 5 years ago.
Proposed 64 bit workaround

Change History

Changed 5 years ago by gillins

Proposed 64 bit workaround

Changed 5 years ago by warmerdam

  • cc hobu added
  • owner changed from hobu to warmerdam

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

Changed 5 years ago by warmerdam

  • keywords 64bit added
  • 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.

Changed 4 years ago by warmerdam

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

Note: See TracTickets for help on using tickets.