yocontra / node-gdal-next

Node.js bindings for GDAL (Geospatial Data Abstraction Library) [Fork]
https://contra.io/node-gdal-next/
Apache License 2.0
75 stars 36 forks source link

Blob field reading causes pointer being freed was not allocated error #15

Closed warrenwyf closed 3 years ago

warrenwyf commented 3 years ago

I am tring to read a vector layer from geopackage data which has a blob field.

After reading several rows nodejs throw errors like this:

node(9501,0x10ce4edc0) malloc: *** error for object 0x102b23e50: pointer being freed was not allocated
node(9501,0x10ce4edc0) malloc: *** set a breakpoint in malloc_error_break to debug

When ignore the blob field, everything is ok.

yocontra commented 3 years ago

@warrenwyf Can you post the code and the file that reproduces the issue?

warrenwyf commented 3 years ago

@warrenwyf Can you post the code and the file that reproduces the issue?

const gdal = require('gdal-next');

const srcDataset = gdal.open(require.resolve('./points.gpkg'));
const layer = srcDataset.layers.get(0);

let feature,
  count = 0;
while (feature = layer.features.next()) {
  count++;

  const obj = { geom: feature.getGeometry().toWKB() };

  obj['name'] = feature.fields.get('name');
  obj['blob'] = feature.fields.get('blob');

  console.log(obj);
}

console.log(count);

Unzip the attachment, save the script, and run it.

points.gpkg.zip

What I got:

image

yocontra commented 3 years ago

@warrenwyf Thanks - seems pretty straightforward, I'll put this on my TODO list and try to look into it this weekend or at the start of next week.

mmomtchev commented 3 years ago

https://github.com/contra/node-gdal-next/pull/33