Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#1712 closed defect (fixed)

Problems writing rasters with NG Python on 64 bit machines

Reported by: Sam Gillingham 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 (1)

gdal_wrap_64patch.cpp (1.6 KB ) - added by Sam Gillingham 17 years ago.
Proposed 64 bit workaround

Download all attachments as: .zip

Change History (4)

by Sam Gillingham, 17 years ago

Attachment: gdal_wrap_64patch.cpp added

Proposed 64 bit workaround

comment:1 by warmerdam, 17 years ago

Cc: hobu added
Owner: changed from hobu to warmerdam

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

comment:2 by warmerdam, 17 years ago

Keywords: 64bit added
Resolution: fixed
Status: newclosed

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.

comment:3 by warmerdam, 17 years ago

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

Note: See TracTickets for help on using tickets.