SymbolixAU / geojsonsf

Conversion between sf and geojson
Other
82 stars 7 forks source link

Segfault, address not mapped #95

Closed latot closed 2 years ago

latot commented 2 years ago

Hi hi, running this we get a super crash, super because need to abort.

geojsonsf::geojson_sf("{\"type\": \"Polygon\", \"coordinates\": [[-70.7355,-33.2402],[-70.7355,-33.2404],[-70.7351,-33.2403],[-70.7351,-33.2401],[-70.7355,-33.2402]]}")
 *** caught segfault ***
address 0xe, cause 'memory not mapped'

Traceback:
 1: rcpp_geojson_to_sf(geojson, expand_geometries)
 2: geojson_to_sf.character(geojson, expand_geometries, buffer_size)
 3: geojson_to_sf(geojson, expand_geometries, buffer_size)
 4: geojsonsf::geojson_sf("{\"type\": \"Polygon\", \"coordinates\": [[-70.7355,-33.2402],[-70.7355,-33.2404],[-70.7351,-33.2403],[-70.7351,-33.2401],[-70.7355,-33.2402]]}")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
R is aborting now ...

All the packages was been installed recently, and the system has no updates, so, it should not be a problem in the libs.

Thx

dcooley commented 2 years ago

thanks for reporting; yes I can also reproduce this crash and will look in to it.

latot commented 2 years ago

Note, the format is wrong, should be:

geojsonsf::geojson_sf("{\"type\": \"Polygon\", \"coordinates\": [[[-70.7355,-33.2402],[-70.7355,-33.2404],[-70.7351,-33.2403],[-70.7351,-33.2401],[-70.7355,-33.2402]]]}")

But the crash above is a little extreme.

Thx!

dcooley commented 2 years ago

yes I've just found that too; your Polygon was incorreclty specified, but the crash still needs handling

dcooley commented 2 years ago

as of v2.0.3 the array is now correctly validated, as per all the other validation checks (for some reason I forgot to add it for LineStrings arrays)

geojsonsf::geojson_sf("{\"type\": \"Polygon\", \"coordinates\": [[-70.7355,-33.2402],[-70.7355,-33.2404],[-70.7351,-33.2403],[-70.7351,-33.2401],[-70.7355,-33.2402]]}")
 Error in rcpp_geojson_to_sf(geojson, expand_geometries) : 
Invalid array object
dcooley commented 2 years ago

2.0.3 accepted on cran

latot commented 2 years ago

Thx!